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


Python pyplot.delaxes方法代碼示例

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


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

示例1: generate_sex_pic

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import delaxes [as 別名]
def generate_sex_pic(self, sex_data):
        """
        生成性別數據圖片
        因為plt在子線程中執行會出現自動彈出彈框並阻塞主線程的行為,plt行為均放在主線程中
        :param sex_data:
        :return:
        """
        # 繪製「性別分布」柱狀圖
        # 'steelblue'
        bar_figure = plt.bar(range(3), sex_data, align='center', color=self.bar_color, alpha=0.8)
        # 添加軸標簽
        plt.ylabel(u'Number')
        # 添加標題
        plt.title(u'Male/Female in your Wechat', fontsize=self.title_font_size)
        # 添加刻度標簽
        plt.xticks(range(3), [u'Male', u'Female', u'UnKnown'])
        # 設置Y軸的刻度範圍
        # 0, male; 1, female; 2, unknown
        max_num = max(sex_data[0], max(sex_data[1], sex_data[2]))
        plt.ylim([0, max_num * 1.1])

        # 為每個條形圖添加數值標簽
        for x, y in enumerate(sex_data):
            plt.text(x, y + len(str(y)), y, ha='center')

        # 保存圖片
        plt.savefig(ALS.result_path + '/2.png')
        # todo 如果不調用此處的關閉,就會導致生成最後一個圖像出現折疊、縮小的混亂
        #bar_figure.remove()
        plt.clf()
        plt.delaxes()
        #plt.close()

        # 顯示圖形
        # plt.show() 
開發者ID:newbietian,項目名稱:WxConn,代碼行數:37,代碼來源:main.py

示例2: delaxes

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import delaxes [as 別名]
def delaxes(ax=None):
    """
    Remove the `Axes` *ax* (defaulting to the current axes) from its figure.

    A KeyError is raised if the axes doesn't exist.
    """
    if ax is None:
        ax = gca()
    ax.figure.delaxes(ax) 
開發者ID:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:11,代碼來源:pyplot.py

示例3: subplot2grid

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import delaxes [as 別名]
def subplot2grid(shape, loc, rowspan=1, colspan=1, fig=None, **kwargs):
    """
    Create an axis at specific location inside a regular grid.

    Parameters
    ----------
    shape : sequence of 2 ints
        Shape of grid in which to place axis.
        First entry is number of rows, second entry is number of columns.

    loc : sequence of 2 ints
        Location to place axis within grid.
        First entry is row number, second entry is column number.

    rowspan : int
        Number of rows for the axis to span to the right.

    colspan : int
        Number of columns for the axis to span downwards.

    fig : `Figure`, optional
        Figure to place axis in. Defaults to current figure.

    **kwargs
        Additional keyword arguments are handed to `add_subplot`.


    Notes
    -----
    The following call ::

        subplot2grid(shape, loc, rowspan=1, colspan=1)

    is identical to ::

        gridspec=GridSpec(shape[0], shape[1])
        subplotspec=gridspec.new_subplotspec(loc, rowspan, colspan)
        subplot(subplotspec)
    """

    if fig is None:
        fig = gcf()

    s1, s2 = shape
    subplotspec = GridSpec(s1, s2).new_subplotspec(loc,
                                                   rowspan=rowspan,
                                                   colspan=colspan)
    a = fig.add_subplot(subplotspec, **kwargs)
    bbox = a.bbox
    byebye = []
    for other in fig.axes:
        if other == a:
            continue
        if bbox.fully_overlaps(other.bbox):
            byebye.append(other)
    for ax in byebye:
        delaxes(ax)

    return a 
開發者ID:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:61,代碼來源:pyplot.py


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