本文整理汇总了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()
示例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)
示例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