當前位置: 首頁>>代碼示例>>Python>>正文


Python matplotlib.Figure方法代碼示例

本文整理匯總了Python中matplotlib.Figure方法的典型用法代碼示例。如果您正苦於以下問題:Python matplotlib.Figure方法的具體用法?Python matplotlib.Figure怎麽用?Python matplotlib.Figure使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在matplotlib的用法示例。


在下文中一共展示了matplotlib.Figure方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import Figure [as 別名]
def run(self, fig):
        """
        Run the exporter on the given figure

        Parmeters
        ---------
        fig : matplotlib.Figure instance
            The figure to export
        """
        # Calling savefig executes the draw() command, putting elements
        # in the correct place.
        if fig.canvas is None:
            canvas = FigureCanvasAgg(fig)
        fig.savefig(io.BytesIO(), format='png', dpi=fig.dpi)
        if self.close_mpl:
            import matplotlib.pyplot as plt
            plt.close(fig)
        self.crawl_fig(fig) 
開發者ID:mpld3,項目名稱:mplexporter,代碼行數:20,代碼來源:exporter.py

示例2: run

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import Figure [as 別名]
def run(self, fig):
        """
        Run the exporter on the given figure

        Parmeters
        ---------
        fig : matplotlib.Figure instance
            The figure to export
        """
        # Calling savefig executes the draw() command, putting elements
        # in the correct place.
        fig.savefig(io.BytesIO(), format='png', dpi=fig.dpi)
        if self.close_mpl:
            import matplotlib.pyplot as plt
            plt.close(fig)
        self.crawl_fig(fig) 
開發者ID:jeanfeydy,項目名稱:lddmm-ot,代碼行數:18,代碼來源:exporter.py

示例3: fit

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import Figure [as 別名]
def fit(self, figure):
        """
        the main function to fit the parameters to the input figure

        Parameters
        ----------
        figure: matplotlib.figure.Figure object or matplotlib.AxesSubplot object
            this function only proceed with one set of axes in the figure.

        Returns
        -------
        matplotlib.figure.Figure object

        """
        if str(type(figure)) == "<class 'matplotlib.axes._subplots.AxesSubplot'>":
            ax = figure
            figure = figure.figure
        elif str(type(figure)) == "<class 'matplotlib.figure.Figure'>":
            ax = figure.axes[0]
        else:
            msg = 'object must be a matplotlib.AxesSubplot or matplotlib.Figure object'
            raise TypeError(msg)
        if len(figure.axes) != 1:
            msg = 'matplotlib.figure object includes more than one axes'
            raise TypeError(msg)
        ax.set_title(self.title)
        ax.set_xlabel(self.xlabel)
        ax.set_ylabel(self.ylabel)
        ax.set_xlim(self.xlim[0], self.xlim[1])
        ax.set_ylim(self.ylim[0], self.ylim[1])
        ax.grid(color=self.grid_color, linestyle=self.grid_linestyle, linewidth=self.grid_linewidth)
        ax.grid(self.grid)
        return figure 
開發者ID:hachmannlab,項目名稱:chemml,代碼行數:35,代碼來源:visualization.py

示例4: plot

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import Figure [as 別名]
def plot(self, dfx, x):
        """
        the main function to plot based on the input dataframe and its header

        Parameters
        ----------
        dfx: pandas dataframe
            the x axis data
        x: string or integer, optional (default=0)
            header or position of data in the dfx

        Returns
        -------
        matplotlib.figure.Figure object

        """
        # check data
        if isinstance(x, str):
            X = dfx[x].values
        elif isinstance(x, int):
            X = dfx.iloc[:, x].values
        else:
            msg = 'x must be string for the header or integer for the postion of data in the dfx'
            raise TypeError(msg)

        # instantiate figure
        fig = plt.figure()
        ax = fig.add_subplot(111)
        tash = ax.hist(X, bins= self.bins, color=self.color, **self.kwargs)
        return fig 
開發者ID:hachmannlab,項目名稱:chemml,代碼行數:32,代碼來源:visualization.py

示例5: interpolation_plot

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import Figure [as 別名]
def interpolation_plot(data, title=None, ax_names=None):
    """Creates black and white interpolation plot

    Creates a black and white interpolation plot from data, which must consist
    of a 0/1 matrix for absence/presence of taxa in genes.

    Parameters
    ----------
    data : numpy.array
        Single or multi-dimensional array with plot data.
    title : str
        Title of the plot.
    ax_names : list
        List with the labels for the x-axis (first element) and y-axis
        (second element).

    Returns
    -------
    fig : matplotlib.pyplot.Figure
        Figure object of the plot.
    _ : None
        Placeholder for the legend object. Not used here but assures
        consistency across other plotting methods.
    _ : None
        Placeholder for the table header list. Not used here but assures
        consistency across other plotting methods.
    """

    plt.rcParams["figure.figsize"] = (8, 6)

    # Use ggpot style
    plt.style.use("ggplot")

    fig, ax = plt.subplots()

    # Setting the aspect ratio proportional to the data
    ar = float(len(data[0])) / float(len(data)) * .2

    ax.imshow(data, interpolation="none", cmap="Greys", aspect=ar)

    ax.grid(False)

    return fig, None, None 
開發者ID:ODiogoSilva,項目名稱:TriFusion,代碼行數:45,代碼來源:plotter.py

示例6: outlier_densisty_dist

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import Figure [as 別名]
def outlier_densisty_dist(data, outliers, outliers_labels=None, ax_names=None,
                          title=None):
    """Creates a density distribution for outlier plots.

    Parameters
    ----------
    data : numpy.array
        1D array containing data points.
    outliers : numpy.array
        1D array containing the outliers.
    outliers_labels : list or numpy.array
        1D array containing the labels for each outlier.
    title : str
        Title of the plot.

    Returns
    -------
    fig : matplotlib.Figure
        Figure object of the plot.
    lgd : matplotlib.Legend
        Legend object of the plot.
    table : list
        Table data in list format. Each item in the list corresponds to a
        table row.
    """

    plt.rcParams["figure.figsize"] = (8, 6)

    fig, ax = plt.subplots()

    # Create density function
    sns.distplot(data, rug=True, hist=False, color="black")

    # Plot outliers
    ax.plot(outliers, np.zeros_like(outliers), "ro", clip_on=False,
            label="Outliers")

    # Create legend
    lgd = ax.legend(frameon=True, loc=2, fancybox=True, shadow=True,
                    framealpha=.8, prop={"weight": "bold"})

    if outliers_labels:
        table = [[os.path.basename(x)] for x in outliers_labels]
    else:
        table = None

    return fig, lgd, table 
開發者ID:ODiogoSilva,項目名稱:TriFusion,代碼行數:49,代碼來源:plotter.py


注:本文中的matplotlib.Figure方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。