Other Parameters
        ----------------
        plot_electrode_numbers: bool, optional
            Plot electrode numbers in the grid, default: False
430868
def plot_grid(self, **kwargs):
        
        fig, ax = plt.subplots(1, 1)
        self.plot_grid_to_ax(ax, **kwargs)
        return fig, ax
1316569
def doplot(self):
        
        w = self
        w.delete(ALL)
        w.coord_grid()
        w.objList.delete(0, END)
        self._plot()
378582
def plot_densities(self, ax=None, **kwargs):
        
        ax, fig, plt = get_ax_fig_plt(ax)

        ax.grid(True)
        ax.set_xlabel('r [Bohr]')
        #ax.set_ylabel('density')

        for i, den_name in enumerate(["ae_core_density", "pseudo_core_density"]):
            rden = getattr(self, den_name)
            label = "$n_c$" if i == 1 else r"$\tilde{n}_c$"
            ax.plot(rden.mesh, rden.mesh * rden.values, label=label, lw=2)

        ax.legend(loc="best")

        return fig
1234201
def plotPowers(ax, params, popkeys, dataset, linestyles, linewidths, transient=200, SCALING_POSTFIX='', markerstyles=None):
    '''
    '''
    
    colors = phlp.get_colors(len(popkeys))
    
    depth = params.electrodeParams['z']
    zpos = np.r_[params.layerBoundaries[:, 0],
                 params.layerBoundaries[-1, 1]]

    for i, layer in enumerate(popkeys):
        f = h5py.File(os.path.join(params.populations_path,
                                   '%s_population_%s' % (layer, dataset) + SCALING_POSTFIX + '.h5' ))
        ax.semilogx(f['data'].value[:, transient:].var(axis=1), depth,
                 color=colors[i],
                 ls=linestyles[i],
                 lw=linewidths[i],
                 marker=None if markerstyles is None else markerstyles[i],
                 markersize=2.5,
                 markerfacecolor=colors[i],
                 markeredgecolor=colors[i],
                 label=layer,
                 clip_on=True
                 )
    
        f.close()
    
    f = h5py.File(os.path.join(params.savefolder, '%ssum' % dataset + SCALING_POSTFIX + '.h5' ))
    ax.plot(f['data'].value[:, transient:].var(axis=1), depth,
                 'k', label='SUM', lw=1.25, clip_on=False)
    
    f.close()

    ax.set_yticks(zpos)
    ax.set_yticklabels([])
    #ax.set_xscale('log')
    try: # numticks arg only exists for latest matplotlib version
        ax.xaxis.set_major_locator(plt.LogLocator(base=10,
                                    subs=np.linspace(-10, 10, 2), numticks=6))
    except:
        ax.xaxis.set_major_locator(plt.LogLocator(base=10,
                                    subs=np.linspace(-10, 10, 2)))
    ax.xaxis.set_minor_locator(plt.LogLocator(base=10, subs=[1.]))
    ax.axis('tight')
1183200
def get_cb_plot(cb, plot=None):
    
    plot = plot or cb.plot
    if isinstance(plot, GeoOverlayPlot):
        plots = [get_cb_plot(cb, p) for p in plot.subplots.values()]
        plots = [p for p in plots if any(s in cb.streams and getattr(s, '_triggering', False)
                                         for s in p.streams)]
        if plots:
            plot = plots[0]
    return plot
1041208
def write_electrodes(self, filename):
        
        fid = open(filename, 'w')
        for i in self.Electrodes:
            fid.write('{0} {1}\n'.format(self.Points[i][0], self.Points[i][1]))
        fid.close()
518937
def plot(self, show_holes=True):
        
        if show_holes:
            edges = self.mesh.extract_edges(boundary_edges=True,
                                            feature_edges=False,
                                            manifold_edges=False)

            plotter = vtki.Plotter()
            plotter.add_mesh(self.mesh, label='mesh')
            plotter.add_mesh(edges, 'r', label='edges')
            plotter.plot()

        else:
            self.mesh.plot(show_edges=True)
1365786
def plot_boundaries(self, **kwargs):
        
        edges = self.extract_edges()

        plotter = vtki.Plotter(off_screen=kwargs.pop('off_screen', False),
                               notebook=kwargs.pop('notebook', None))
        plotter.add_mesh(edges, 'r', style='wireframe', legend='Edges')
        plotter.add_mesh(self, legend='Mesh', **kwargs)
        return plotter.show()
1060775
def plotER(self,*args,**kwargs):
        
        if kwargs.pop('normed',False):
            kwargs['d2']= 'ERnorm'
        else:
            kwargs['d2']= 'ER'
        return self.plot(*args,**kwargs)
362879
def on_electrode_states_updated(self, states):
        '''
        
        '''
        states['electrode_states'] = \
            states['electrode_states'].combine_first(self.canvas_slave
                                                     .electrode_states)
        self.on_electrode_states_set(states)
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
1068846
def _plotxw(self,*args,**kwargs): #pragma: no cover
        
        xw= self.xw()
        #BOVY: CHECK THAT THIS IS CORRECT
        plot.bovy_plot(2.*m.pi*nu.fft.fftfreq(len(self.t),
                                              d=(self.t[1]-self.t[0]))\
                           [0:len(xw)],
                       xw,*args,**kwargs)
1363293
def render_electrode_shapes(self, df_shapes=None, shape_scale=0.8,
                                fill=(1, 1, 1)):
        '''
        
        '''
        surface = self.get_surface()
        if df_shapes is None:
            if hasattr(self.canvas, 'df_canvas_shapes'):
                df_shapes = self.canvas.df_canvas_shapes
            else:
                return surface
        if 'x_center' not in df_shapes or 'y_center' not in df_shapes:
            # No center points have been computed for shapes.
            return surface

        cairo_context = cairo.Context(surface)

        df_shapes = df_shapes.copy()
        # Scale shapes to leave shape edges uncovered.
        df_shapes[['x', 'y']] = (df_shapes[['x_center', 'y_center']] +
                                 df_shapes[['x_center_offset',
                                            'y_center_offset']].values *
                                 shape_scale)

        for path_id, df_path_i in (df_shapes.groupby(self.canvas
                                                     .shape_i_columns)[['x',
                                                                        'y']]):
            # Use attribute lookup for `x` and `y`, since it is considerably
            # faster than `get`-based lookup using columns name strings.
            vertices_x = df_path_i.x.values
            vertices_y = df_path_i.y.values
            cairo_context.move_to(vertices_x[0], vertices_y[0])
            for x, y in itertools.izip(vertices_x[1:], vertices_y[1:]):
                cairo_context.line_to(x, y)
            cairo_context.close_path()

            # Draw filled shape to indicate actuated electrode state.
            cairo_context.set_source_rgba(*fill)
            cairo_context.fill()
        return surface
1289639
def add_stabilizer_nodes(boundaries_raw, electrodes, nr_nodes_between):
    
    boundaries = []

    boundaries = boundaries_raw
    # find first electrode in boundary
    for nr in range(electrodes.shape[0] - 1):
        index0 = np.where(
            (boundaries[:, 0] == electrodes[nr, 0]) &
            (boundaries[:, 1] == electrodes[nr, 1])
        )[0]

        index1 = np.where(
            (boundaries[:, 0] == electrodes[nr + 1, 0]) &
            (boundaries[:, 1] == electrodes[nr + 1, 1])
        )[0]

        index0 = index0[0]
        index1 = index1[0]
        if index1 - index0 < 0:
            index0, index1 = index1, index0
        running_index = index0
        nr_nodes = index1 - index0 - 1
        while nr_nodes < nr_nodes_between:
            # determine line equation
            xy0 = boundaries[running_index, 0:2]
            xy1 = boundaries[running_index + 1, 0:2]

            direction = xy1 - xy0
            heading = direction / np.sqrt(np.sum(direction ** 2))

            # new node
            xy_new = xy0 + heading * direction / 2.0
            a = boundaries[running_index, 2][np.newaxis]
            xyb = np.hstack((xy_new, a))
            boundaries = np.insert(boundaries, running_index + 1, xyb, axis=0)

            # 2, because we have to count the new one
            running_index += 2
            index1 += 1
            nr_nodes += 1

            if running_index == index1:
                running_index = index0

    return boundaries
1030525
def plot_mv_voltages(self, **kwargs):
        
        if self.network.pypsa is not None:
            try:
                v_res = self.network.results.v_res()
            except:
                logging.warning("Voltages `pfa_v_mag_pu` from power flow "
                                "analysis must be available to plot them.")
                return
            plots.mv_grid_topology(
                self.network.pypsa, self.network.config,
                timestep=kwargs.get('timestep', None),
                node_color='voltage',
                filename=kwargs.get('filename', None),
                grid_district_geom=kwargs.get('grid_district_geom', True),
                background_map=kwargs.get('background_map', True),
                voltage=v_res,
                limits_cb_nodes=kwargs.get('limits_cb_nodes', None),
                xlim=kwargs.get('xlim', None), ylim=kwargs.get('ylim', None),
                title=kwargs.get('title', ''))
        else:
            logging.warning("pypsa representation of MV grid needed to "
                            "plot voltages.")
917552
def tc_at_grid_col(self, idx):
        
        grid_col = 0
        for tc in self.tc_lst:
            if grid_col == idx:
                return tc
            grid_col += tc.grid_span
            if grid_col > idx:
                raise ValueError('no cell on grid column %d' % idx)
        raise ValueError('index out of bounds')
1340390
def plot(self, method_labels=None, exodata_credit=True):
        

        if method_labels is None:
            method_labels = self.methods_to_plot

        plot_matrix, year_list, discovery_years = self.generate_data()

        fig = plt.figure()
        ax = fig.add_subplot(1, 1, 1)

        ind = np.arange(len(year_list))

        # output from seaborn.color_palette("Set1", n_colors=8)
        colors = [(0.89411765336990356, 0.10196078568696976, 0.10980392247438431),
                  (0.21602460800432691, 0.49487120380588606, 0.71987698697576341),
                  (0.30426760128900115, 0.68329106055054012, 0.29293349969620797),
                  (0.60083047361934883, 0.30814303335021526, 0.63169552298153153),
                  (1.0, 0.50591311045721465, 0.0031372549487095253),
                  (0.99315647868549117, 0.9870049982678657, 0.19915417450315812),
                  (0.65845446095747107, 0.34122261685483596, 0.1707958535236471),
                  (0.95850826852461868, 0.50846600392285513, 0.74492888871361229)]

        width = 0.9
        bottom = np.zeros_like(year_list)
        for i, method in enumerate(self.methods_to_plot):
            bar_data = [plot_matrix[year][method] for year in year_list]
            plt.bar(ind, bar_data, width, color=colors[i], bottom=bottom, label=method_labels[i], linewidth=0)

            bottom += np.array(bar_data) # plot the next bar stacked

        plt.ylabel('Number of planets', fontsize=14)
        plt.xlabel('Year', fontsize=14)
        plt.xticks(ind+width/2., year_list, rotation=70, fontsize=13)
        plt.xlim(0, ind[-1]+1)
        plt.legend(loc=2, fontsize=13)

        if exodata_credit is True:
            ax.text(2, 420, 'Generated by ExoData on {}'.format(time.strftime("%d/%m/%Y")), fontsize=11)

        for i, year in enumerate(year_list):
            try:
                total_planets = discovery_years[year]
            except KeyError:  # year with no planets discovered
                continue  # Dont label
            y_pos = bottom[i]+10
            x_pos = i

            ax.text(x_pos, y_pos, '{}'.format(total_planets), fontsize=9)

        plt.grid(b=True, which='both', color='0.9', linestyle='-')

        return fig