Create fig and axes if needed and layout axes in fig.
351802
def prepare_axes(wave, flux, fig=None, ax_lower=(0.1, 0.1),
                 ax_dim=(0.85, 0.65)):
    """"""
    # Axes location in figure.
    if not fig:
        fig = plt.figure()
    ax = fig.add_axes([ax_lower[0], ax_lower[1], ax_dim[0], ax_dim[1]])
    ax.plot(wave, flux)
    return fig, ax
1246046
def load_axes(d):
        """"""
        import matplotlib.pyplot as plt
        fig = plt.figure(d.pop('fig', None))
        proj = d.pop('projection', None)
        spines = d.pop('spines', None)
        invert_yaxis = d.pop('yaxis_inverted', None)
        invert_xaxis = d.pop('xaxis_inverted', None)
        if mpl.__version__ >= '2.0' and 'axisbg' in d:  # axisbg is depreceated
            d['facecolor'] = d.pop('axisbg')
        elif mpl.__version__ < '2.0' and 'facecolor' in d:
            d['axisbg'] = d.pop('facecolor')
        if proj is not None and not isinstance(proj, six.string_types):
            proj = getattr(import_module(proj[0]), proj[1])()
        if d.pop('is_subplot', None):
            grid_spec = mpl.gridspec.GridSpec(*d.pop('grid_spec', (1, 1)))
            subplotspec = mpl.gridspec.SubplotSpec(
                grid_spec, *d.pop('subplotspec', (1, None)))
            return fig.add_subplot(subplotspec, projection=proj, **d)
        ret = fig.add_axes(*d.pop('args', []), projection=proj, **d)
        if spines is not None:
            for key, val in spines.items():
                ret.spines[key].update(val)
        if invert_xaxis:
            if ret.get_xlim()[0] < ret.get_xlim()[1]:
                ret.invert_xaxis()
        if invert_yaxis:
            if ret.get_ylim()[0] < ret.get_ylim()[1]:
                ret.invert_yaxis()
        return ret
998460
def plot(self, figsize=None, ax=None, **kwargs):
        '''
        
        '''
        if ax is None:
            fig, ax = plt.subplots(figsize=figsize)
        ax.set_aspect('equal')
        ax.matshow(self.raster, **kwargs)
        plt.draw()
        return ax
124255
def make_plots(self, prefix, mcube_map=None, **kwargs):
        """"""

        #mcube_maps = kwargs.pop('mcube_maps', None)
        if mcube_map is None:
            mcube_map = self.model_counts_map()

        plotter = plotting.AnalysisPlotter(self.config['plotting'],
                                           fileio=self.config['fileio'],
                                           logging=self.config['logging'])
        plotter.run(self, mcube_map, prefix=prefix, **kwargs)
1372364
def show_xys(self, xs, ys, imgsize:int=4, figsize:Optional[Tuple[int,int]]=None, **kwargs):
        ""
        axs = subplots(len(xs), 2, imgsize=imgsize, figsize=figsize)
        for i, (x,y) in enumerate(zip(xs,ys)):
            x.show(ax=axs[i,0], **kwargs)
            y.show(ax=axs[i,1], **kwargs)
        plt.tight_layout()
909410
def _create_figure(kwargs: Mapping[str, Any]) -> dict:
    """"""
    return {
        "$schema": "https://vega.github.io/schema/vega/v3.json",
        "width": kwargs.pop("width", DEFAULT_WIDTH),
        "height": kwargs.pop("height", DEFAULT_HEIGHT),
        "padding": kwargs.pop("padding", DEFAULT_PADDING)
    }
22346
def create_slice(self, context):
        
        model = self._model
        axes = self._image.axes
        """ :type: matplotlib.axes.Axes """

        axes.set_title(model.title, fontsize=12)
        axes.tick_params(axis='both')
        axes.set_ylabel(model.y_axis_name, fontsize=9)
        axes.set_xlabel(model.x_axis_name, fontsize=9)

        axes.get_xaxis().set_major_formatter(FuncFormatter(model.x_axis_formatter))
        axes.get_xaxis().set_major_locator(AutoLocator())

        axes.get_yaxis().set_major_formatter(FuncFormatter(model.y_axis_formatter))
        axes.get_yaxis().set_major_locator(AutoLocator())

        for label in (axes.get_xticklabels() + axes.get_yticklabels()):
            label.set_fontsize(9)

        self._reset_zoom()

        axes.add_patch(self._vertical_indicator)
        axes.add_patch(self._horizontal_indicator)
        self._update_indicators(context)

        self._image.set_cmap(cmap=context['colormap'])

        self._view_limits = context["view_limits"][self._model.index_direction['name']]

        if model.data is not None:
            self._image.set_data(model.data)
461758
def _get_axes(dim, subplots_kwargs=dict()):
    

    import matplotlib.pyplot as plt

    if dim > 1:
        n_panels = int(dim * (dim - 1) / 2)
    else:
        n_panels = 1
    figsize = subplots_kwargs.pop('figsize', (4*n_panels, 4))
    fig, axes = plt.subplots(1, n_panels, figsize=figsize,
                             **subplots_kwargs)

    if n_panels == 1:
        axes = [axes]

    else:
        axes = axes.flat

    return axes
454268
function buildAxis() {
            axis = d3Axis.axisBottom(xScale)
                .ticks(ticks)
                .tickPadding(tickPadding)
                .tickFormat(d3Format.format(numberFormat));
        }
874055
def prepare_venn_axes(ax, centers, radii):
    '''
    
    '''
    ax.set_aspect('equal')
    ax.set_xticks([])
    ax.set_yticks([])
    min_x = min([centers[i][0] - radii[i] for i in range(len(radii))])
    max_x = max([centers[i][0] + radii[i] for i in range(len(radii))])
    min_y = min([centers[i][1] - radii[i] for i in range(len(radii))])
    max_y = max([centers[i][1] + radii[i] for i in range(len(radii))])
    ax.set_xlim([min_x - 0.1, max_x + 0.1])
    ax.set_ylim([min_y - 0.1, max_y + 0.1])
    ax.set_axis_off()
302290
def _layout(self):
        
        # Ensure the axes are created if not hist, then return.
        if not self.hist:
            self.ax
            return

        # Ensure matplotlib version compatibility
        if make_axes_locatable is None:
            raise YellowbrickValueError((
                "joint plot histograms requires matplotlib 2.0.2 or greater "
                "please upgrade matplotlib or set hist=False on the visualizer"
            ))

        # Create the new axes for the histograms
        divider = make_axes_locatable(self.ax)
        self._xhax = divider.append_axes("top", size=1, pad=0.1, sharex=self.ax)
        self._yhax = divider.append_axes("right", size=1, pad=0.1, sharey=self.ax)

        # Modify the display of the axes
        self._xhax.xaxis.tick_top()
        self._yhax.yaxis.tick_right()
        self._xhax.grid(False, axis='y')
        self._yhax.grid(False, axis='x')
99722
def plot_figures():
    """"""
    rc("figure", figsize=[8.,4.])
    rc("figure.subplot", left=.08, top=.95, right=.98)
    rc("image", cmap="gray")
    seed(1000)

    Q1 = cp.Gamma(2)
    Q2 = cp.Normal(0, Q1)
    Q = cp.J(Q1, Q2)
    #end

    subplot(121)
    s,t = meshgrid(linspace(0,5,200), linspace(-6,6,200))
    contourf(s,t,Q.pdf([s,t]),50)
    xlabel("$q_1$")
    ylabel("$q_2$")
    subplot(122)
    Qr = Q.sample(500)
    scatter(*Qr, s=10, c="k", marker="s")
    xlabel("$Q_1$")
    ylabel("$Q_2$")
    axis([0,5,-6,6])

    savefig("multivariate.png"); clf()

    Q2 = cp.Gamma(1)
    Q1 = cp.Normal(Q2**2, Q2+1)
    Q = cp.J(Q1, Q2)
    #end

    subplot(121)
    s,t = meshgrid(linspace(-4,7,200), linspace(0,3,200))
    contourf(s,t,Q.pdf([s,t]),30)
    xlabel("$q_1$")
    ylabel("$q_2$")
    subplot(122)
    Qr = Q.sample(500)
    scatter(*Qr)
    xlabel("$Q_1$")
    ylabel("$Q_2$")
    axis([-4,7,0,3])

    savefig("multivariate2.png"); clf()
72896
def add_plot(x, y, xl, yl, fig, ax, LATEX=False, linestyle=None, **kwargs):
    """"""
    if LATEX:
        xl_data = xl[1]  # NOQA
        yl_data = yl[1]
    else:
        xl_data = xl[0]  # NOQA
        yl_data = yl[0]

    for idx in range(len(y)):
        ax.plot(x, y[idx], label=yl_data[idx], linestyle=linestyle)

    ax.legend(loc='upper right')
    ax.set_ylim(auto=True)
1218530
def load_figure(self, fig, fmt):
        """"""
        self.figcanvas.load_figure(fig, fmt)
        self.scale_image()
        self.figcanvas.repaint()
960969
def setup():
    
    import sys
    already_loaded = 'matplotlib' in sys.modules

    # just make sure we can access matplotlib as mpl
    import matplotlib as mpl

    if not already_loaded:
        mpl.use('Agg')

    import matplotlib.pyplot as plt

    plt.style.use('seaborn')

    general_settings()

    import mpl_toolkits.axes_grid1 as axes_grid1
    axes_grid1
    return plt, mpl
727912
def _build(self):
        
        if not self.layers:
            self += geom_blank()

        self.layout = Layout()
        layers = self.layers
        scales = self.scales
        layout = self.layout

        # Give each layer a copy of the data that it will need
        layers.generate_data(self.data)

        # Initialise panels, add extra data for margins & missing
        # facetting variables, and add on a PANEL variable to data
        layout.setup(layers, self)

        # Compute aesthetics to produce data with generalised
        # variable names
        layers.compute_aesthetics(self)

        # Transform data using all scales
        layers.transform(scales)

        # Map and train positions so that statistics have access
        # to ranges and all positions are numeric
        layout.train_position(layers, scales.x, scales.y)
        layout.map_position(layers)

        # Apply and map statistics
        layers.compute_statistic(layout)
        layers.map_statistic(self)

        # Make sure missing (but required) aesthetics are added
        scales.add_missing(('x', 'y'))

        # Prepare data in geoms
        # e.g. from y and width to ymin and ymax
        layers.setup_data()

        # Apply position adjustments
        layers.compute_position(layout)

        # Reset position scales, then re-train and map.  This
        # ensures that facets have control over the range of
        # a plot.
        layout.reset_position_scales()
        layout.train_position(layers, scales.x, scales.y)
        layout.map_position(layers)

        # Train and map non-position scales
        npscales = scales.non_position_scales()
        if len(npscales):
            layers.train(npscales)
            layers.map(npscales)

        # Train coordinate system
        layout.setup_panel_params(self.coordinates)

        # fill in the defaults
        layers.use_defaults()

        # Allow stats to modify the layer data
        layers.finish_statistics()

        # Allow layout to modify data before rendering
        layout.finish_data(layers)
814853
def get_base_layout(figs):
	
	layout={}
	for fig in figs:
		if not isinstance(fig,dict):
			fig=fig.to_dict()
		for k,v in list(fig['layout'].items()):
			layout[k]=v
	return layout