Plot summary graphs.

        Args:
            show: shows the figure if True.
            save: saves the figure if True.
            figure_type: optional, figure type to create.
492020
def plot_summaries(self, show=False, save=True, figure_type=None):
        

        if not figure_type:
            figure_type = self.default_figure_type

        if not figure_type in self.default_figure_types:
            logger.debug("unknown figure type selected")
            figure_type = self.default_figure_type

        color_list, symbol_list = self._create_colors_markers_list()
        summary_df = self.summary_df
        selected_summaries = self.selected_summaries
        batch_dir = self.batch_dir
        batch_name = self.name
        fig, ax = plot_summary_figure(self.info_df, summary_df, color_list,
                                      symbol_list, selected_summaries,
                                      batch_dir, batch_name, show=show,
                                      save=save, figure_type=figure_type)
        self.figure[figure_type] = fig
        self.axes[figure_type] = ax
324874
def on_click_plot_widget(self, event):
        
        self.plot.source = self.sources
        self.plot.visible = event.new
        if self.plot.visible:
            self.plot.watchers.append(
                self.select.widget.link(self.plot, value='source'))
911110
def plot(self, tag, mpl_plt, step=None, close_plot=True):
    
    if step is None:
      step = self._step
    else:
      self._step = step
    fig = mpl_plt.get_current_fig_manager()
    img_w, img_h = fig.canvas.get_width_height()
    image_buf = io.BytesIO()
    mpl_plt.savefig(image_buf, format='png')
    image_summary = Summary.Image(
        encoded_image_string=image_buf.getvalue(),
        colorspace=4,  # RGBA
        height=img_h,
        width=img_w)
    summary = Summary(value=[Summary.Value(tag=tag, image=image_summary)])
    self.add_summary(summary, step)
    if close_plot:
      mpl_plt.close()
605039
def save(self_or_cls, obj, basename, fmt='auto', key={}, info={}, options=None, **kwargs):
        
        if info or key:
            raise Exception('Renderer does not support saving metadata to file.')

        if isinstance(obj, (Plot, NdWidget)):
            plot = obj
        else:
            with StoreOptions.options(obj, options, **kwargs):
                plot = self_or_cls.get_plot(obj)

        if (fmt in list(self_or_cls.widgets.keys())+['auto']) and len(plot) > 1:
            with StoreOptions.options(obj, options, **kwargs):
                if isinstance(basename, basestring):
                    basename = basename+'.html'
                self_or_cls.export_widgets(plot, basename, fmt)
            return

        rendered = self_or_cls(plot, fmt)
        if rendered is None: return
        (data, info) = rendered
        encoded = self_or_cls.encode(rendered)
        prefix = self_or_cls._save_prefix(info['file-ext'])
        if prefix:
            encoded = prefix + encoded
        if isinstance(basename, (BytesIO, StringIO)):
            basename.write(encoded)
            basename.seek(0)
        else:
            filename ='%s.%s' % (basename, info['file-ext'])
            with open(filename, 'wb') as f:
                f.write(encoded)
980970
def show(self, **kwargs):
        
        kwargs.setdefault('show', True)
        kwargs.setdefault('save', False)
        kwargs.setdefault('animate', False)
        return self._show_or_save(**kwargs)
597556
def plot(self):
		'''
		
		'''
		pl.plot(self.x, self.y, '.')
		pl.plot(self.x_int, self.y_int)
		pl.grid(True)
		pl.show()
103059
def plot_stats(statistics, ylog=False, view=False, filename='avg_fitness.svg'):
    
    if plt is None:
        warnings.warn("This display is not available due to a missing optional dependency (matplotlib)")
        return

    generation = range(len(statistics.most_fit_genomes))
    best_fitness = [c.fitness for c in statistics.most_fit_genomes]
    avg_fitness = np.array(statistics.get_fitness_mean())
    stdev_fitness = np.array(statistics.get_fitness_stdev())

    plt.plot(generation, avg_fitness, 'b-', label="average")
    plt.plot(generation, avg_fitness - stdev_fitness, 'g-.', label="-1 sd")
    plt.plot(generation, avg_fitness + stdev_fitness, 'g-.', label="+1 sd")
    plt.plot(generation, best_fitness, 'r-', label="best")

    plt.title("Population's average and best fitness")
    plt.xlabel("Generations")
    plt.ylabel("Fitness")
    plt.grid()
    plt.legend(loc="best")
    if ylog:
        plt.gca().set_yscale('symlog')

    plt.savefig(filename)
    if view:
        plt.show()

    plt.close()
1312279
def show(self, ax:plt.Axes=None, figsize:tuple=(3,3), title:Optional[str]=None, hide_axis:bool=True, **kwargs):
        ""
        if ax is None: _,ax = plt.subplots(figsize=figsize)
        pnt = scale_flow(FlowField(self.size, self.data), to_unit=False).flow.flip(1)
        params = {'s': 10, 'marker': '.', 'c': 'r', **kwargs}
        ax.scatter(pnt[:, 0], pnt[:, 1], **params)
        if hide_axis: ax.axis('off')
        if title: ax.set_title(title)
923007
def save_plot(axes="gca", path=None):
    

    global line_attributes

    # choose a path to save to
    if path==None: path = _s.dialogs.Save("*.plot", default_directory="save_plot_default_directory")

    if path=="":
        print("aborted.")
        return

    if not path.split(".")[-1] == "plot": path = path+".plot"

    f = file(path, "w")

    # if no argument was given, get the current axes
    if axes=="gca": axes=_pylab.gca()

    # now loop over the available lines
    f.write("title="  +axes.title.get_text().replace('\n', '\\n')+'\n')
    f.write("xlabel="+axes.xaxis.label.get_text().replace('\n','\\n')+'\n')
    f.write("ylabel="+axes.yaxis.label.get_text().replace('\n','\\n')+'\n')

    for l in axes.lines:
        # write the data header
        f.write("trace=new\n")
        f.write("legend="+l.get_label().replace('\n', '\\n')+"\n")

        for a in line_attributes: f.write(a+"="+str(_pylab.getp(l, a)).replace('\n','')+"\n")

        # get the data
        x = l.get_xdata()
        y = l.get_ydata()

        # loop over the data
        for n in range(0, len(x)): f.write(str(float(x[n])) + " " + str(float(y[n])) + "\n")

    f.close()
54002
def render(self):
        '''
        '''

        fig, ax = plt.subplots()
        self.data_object._render_plot(ax)
        return fig
638429
def plotCost(cost_list, output=None):
    

    if not import_fail:

        if isinstance(output, type(None)):
            file_name = 'cost_function.png'
        else:
            file_name = output + '_cost_function.png'

        plt.figure()
        plt.plot(np.log10(cost_list), 'r-')
        plt.title('Cost Function')
        plt.xlabel('Iteration')
        plt.ylabel(r'$\log_{10}$ Cost')
        plt.savefig(file_name)
        plt.close()

        print(' - Saving cost function data to:', file_name)

    else:

        warn('Matplotlib not installed.')
1090109
def plot(self, figure_list):
        '''
        

        '''

        #TODO: be smarter about how we plot ScriptIterator
        if self._current_subscript_stage is not None:
            if self._current_subscript_stage['current_subscript'] is not None:
                self._current_subscript_stage['current_subscript'].plot(figure_list)

        if (self.is_running is False) and not (self.data == {} or self.data is None):

            script_names = list(self.settings['script_order'].keys())
            script_indices = [self.settings['script_order'][name] for name in script_names]
            _, sorted_script_names = list(zip(*sorted(zip(script_indices, script_names))))

            last_script = self.scripts[sorted_script_names[-1]]

            last_script.force_update()  # since we use the last script plot function we force it to refresh

            axes_list = last_script.get_axes_layout(figure_list)

            # catch error is _plot function doens't take optional data argument
            try:
                last_script._plot(axes_list, self.data)
            except TypeError as err:
                print((warnings.warn('can\'t plot average script data because script.plot function doens\'t take data as optional argument. Plotting last data set instead')))
                print((err.message))
                last_script.plot(figure_list)
217494
def graph(data):
    """"""
    title = data['name'] + ' (' + data['rating'] + ') '
    plt.title(title)
    plt.xlabel('Episode Number')
    plt.ylabel('Ratings')
    rf,ef=graphdata(data)
    col=['red', 'green' , 'orange']
    for i in range(len(rf)):
        x,y=ef[i],rf[i]
        k = i + 1
        plt.plot(x, y,color=col[i%3])
    x1, x2, y1, y2 = plt.axis()
    y2 = 10
    if y1 > 7:
        y1 = 7
    plt.axis([x1, x2, y1, y2])
    plt.show()
444070
def _plot_figure(self, idx, fig_format='json'):
        
        self.plot.update(idx)
        if self.embed:
            return self.renderer.diff(self.plot)
435868
def plot_init(fignum, w, h):
    
    global fig_x_pos, fig_y_pos, plt_num
    dpi = 80
    if isServer:
        dpi = 240
    # plt.ion()
    plt_num += 1
    fig = plt.figure(num=fignum, figsize=(w, h), dpi=dpi)
    if (not isServer) and (not set_env.IS_NOTEBOOK):
        plt.get_current_fig_manager().show()
        # plt.get_current_fig_manager().window.wm_geometry('+%d+%d' %
        # (fig_x_pos,fig_y_pos)) # this only works with matplotlib.use('TKAgg')
        fig_x_pos = fig_x_pos + dpi * (w) + 25
        if plt_num == 3:
            plt_num = 0
            fig_x_pos = 25
            fig_y_pos = fig_y_pos + dpi * (h) + 25
        plt.figtext(.02, .01, version_num)
# plt.connect('button_press_event',click)
#
    # plt.ioff()
    return fig
1032563
def plot(
        self,
        show_coedges=True,
        show_centroids=True,
        mesh_color="k",
        nondelaunay_edge_color="#d62728",  # mpl 2.0 default red
        boundary_edge_color=None,
        comesh_color=(0.8, 0.8, 0.8),
        show_axes=True,
    ):
        
        # Importing matplotlib takes a while, so don't do that at the header.
        from matplotlib import pyplot as plt
        from matplotlib.collections import LineCollection

        # from mpl_toolkits.mplot3d import Axes3D
        fig = plt.figure()
        ax = fig.gca()
        # plt.axis("equal")
        if not show_axes:
            ax.set_axis_off()

        xmin = numpy.amin(self.node_coords[:, 0])
        xmax = numpy.amax(self.node_coords[:, 0])
        ymin = numpy.amin(self.node_coords[:, 1])
        ymax = numpy.amax(self.node_coords[:, 1])

        width = xmax - xmin
        xmin -= 0.1 * width
        xmax += 0.1 * width

        height = ymax - ymin
        ymin -= 0.1 * height
        ymax += 0.1 * height

        # ax.set_xlim(xmin, xmax)
        # ax.set_ylim(ymin, ymax)

        if self.edges is None:
            self.create_edges()

        # Get edges, cut off z-component.
        e = self.node_coords[self.edges["nodes"]][:, :, :2]
        # Plot regular edges, mark those with negative ce-ratio red.
        ce_ratios = self.ce_ratios_per_interior_edge
        pos = ce_ratios >= 0

        is_pos = numpy.zeros(len(self.edges["nodes"]), dtype=bool)
        is_pos[self._edge_to_edge_gid[2][pos]] = True

        # Mark Delaunay-conforming boundary edges
        is_pos_boundary = self.ce_ratios[self.is_boundary_edge] >= 0
        is_pos[self._edge_to_edge_gid[1][is_pos_boundary]] = True

        line_segments0 = LineCollection(e[is_pos], color=mesh_color)
        ax.add_collection(line_segments0)
        #
        line_segments1 = LineCollection(e[~is_pos], color=nondelaunay_edge_color)
        ax.add_collection(line_segments1)

        if show_coedges:
            # Connect all cell circumcenters with the edge midpoints
            cc = self.cell_circumcenters

            edge_midpoints = 0.5 * (
                self.node_coords[self.edges["nodes"][:, 0]]
                + self.node_coords[self.edges["nodes"][:, 1]]
            )

            # Plot connection of the circumcenter to the midpoint of all three
            # axes.
            a = numpy.stack(
                [cc[:, :2], edge_midpoints[self.cells["edges"][:, 0], :2]], axis=1
            )
            b = numpy.stack(
                [cc[:, :2], edge_midpoints[self.cells["edges"][:, 1], :2]], axis=1
            )
            c = numpy.stack(
                [cc[:, :2], edge_midpoints[self.cells["edges"][:, 2], :2]], axis=1
            )

            line_segments = LineCollection(
                numpy.concatenate([a, b, c]), color=comesh_color
            )
            ax.add_collection(line_segments)

        if boundary_edge_color:
            e = self.node_coords[self.edges["nodes"][self.is_boundary_edge_individual]][
                :, :, :2
            ]
            line_segments1 = LineCollection(e, color=boundary_edge_color)
            ax.add_collection(line_segments1)

        if show_centroids:
            centroids = self.control_volume_centroids
            ax.plot(
                centroids[:, 0],
                centroids[:, 1],
                linestyle="",
                marker=".",
                color="#d62728",
            )

        return fig
375092
def display_graph(g, format='svg', include_asset_exists=False):
    
    try:
        import IPython.display as display
    except ImportError:
        raise NoIPython("IPython is not installed.  Can't display graph.")

    if format == 'svg':
        display_cls = display.SVG
    elif format in ("jpeg", "png"):
        display_cls = partial(display.Image, format=format, embed=True)

    out = BytesIO()
    _render(g, out, format, include_asset_exists=include_asset_exists)
    return display_cls(data=out.getvalue())