matplot学习:常用函数

add_axes(*args, **kwargs)

maplot.figure.Figure.add_axes(Pythonmethod,infigure)
在位置rect[left,bottom,width,height]上增加一个坐标轴
<code>
rect = l,b,w,h
fig.add_axes(rect)
</code>
具有label参数可以添加label
<code>
fig.add_axes(rect,label='axes1')
fig.add_axes(rect,label='axes2')
</code>
在少数情况下,如果一个Axes的实体已经被声明但是没有加入到figure中,可以直接使用add_axes将他加入
<code>
fig.add_axes(ax)
</code>

fig.tight_layout()

可以解决标签重叠问题
<code>
fig, axes = plt.subplots(nrows=1, ncols=2)

for ax in axes:
ax.plot(x, y, 'r')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_title('title')

fig.tight_layout()
fig
</code>

matplot.figure(Python module, in figure)

matplotlib.axes.Axes.twinx(Python method, in matplot.axes.Axes.twinx)

使用同一个x轴,可以用来实现双坐标轴
例如:
<code>
ax.plot()
ax2.twinx(ax)
</code>

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容