Python matplotlib.pyplot.delaxes() Examples

The following are 9 code examples of matplotlib.pyplot.delaxes(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module matplotlib.pyplot , or try the search function .
Example #1
Source File: main.py    From WxConn with MIT License 5 votes vote down vote up
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() 
Example #2
Source File: pyplot.py    From GraphicDesignPatternByPython with MIT License 5 votes vote down vote up
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) 
Example #3
Source File: pyplot.py    From python3_ios with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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) 
Example #4
Source File: pyplot.py    From coffeegrindsize with MIT License 5 votes vote down vote up
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) 
Example #5
Source File: pyplot.py    From CogAlg with MIT License 5 votes vote down vote up
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) 
Example #6
Source File: pyplot.py    From GraphicDesignPatternByPython with MIT License 4 votes vote down vote up
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 
Example #7
Source File: pyplot.py    From python3_ios with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
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 
Example #8
Source File: pyplot.py    From coffeegrindsize with MIT License 4 votes vote down vote up
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 
Example #9
Source File: pyplot.py    From CogAlg with MIT License 4 votes vote down vote up
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