查看matplotlib文档,似乎添加AxesSubplot到a 的标准方法Figure是使用Figure.add_subplot:
from matplotlib import pyplot
fig = pyplot.figure()
ax = fig.add_subplot(1,1,1)
ax.hist( some params .... )
Run Code Online (Sandbox Code Playgroud)
我希望能够AxesSubPlot独立于图形创建类似对象,因此我可以在不同的图中使用它们.就像是
fig = pyplot.figure()
histoA = some_axes_subplot_maker.hist( some params ..... )
histoA = some_axes_subplot_maker.hist( some other params ..... )
# make one figure with both plots
fig.add_subaxes(histo1, 211)
fig.add_subaxes(histo1, 212)
fig2 = pyplot.figure()
# make a figure with the first plot only
fig2.add_subaxes(histo1, 111)
Run Code Online (Sandbox Code Playgroud)
这是可能的matplotlib,如果可以,我该怎么做?
更新:我还没有设法解除Axes和Figures的创建,但是下面的答案中的示例可以很容易地在new或olf Figure实例中重用以前创建的轴.这可以通过一个简单的功能来说明:
def plot_axes(ax, fig=None, …Run Code Online (Sandbox Code Playgroud) 我一直遇到在Matplotlib中生成出版物"完美"图像的问题(即更改字体大小,标记大小,图形大小,刻度数等...).
基本上,我想做这里描述的内容:http://www.scipy.org/Cookbook/Matplotlib/LaTeX_Examples,除非图已经完成.即我想创建一个接受Figure对象的函数,并进行所有必要的更改,其中一些可用作输入参数.这样,当我决定在论文中使用数字时,我不必总是修改我的脚本.
有没有一种有效的方法来实现这一目标?
注意我通常使用Ipython.