【发布时间】:2013-06-20 03:38:28
【问题描述】:
我看到了很多解释如何以不同大小保存图的示例,但没有一个使用 host_subplots。我想将图形保存为当我最大化最初出现的绘图的窗口时的样子。以下块是我一直在做的一个较短的版本:
>>> import matplotlib.pyplot as plt
>>> import mpl_toolkits.axisartist as AA
>>> from mpl_toolkits.axes_grid1 import host_subplot
>>>
>>> host = host_subplot(111, axes_class = AA.Axes)
>>> plt.subplots_adjust(right=0.75)
>>>
>>> time = [1, 2, 3, 4, 5]
>>> velocity = [2, 4, 6, 8, 10]
>>> another_variable = [15, 20, 25, 40, 55]
>>>
>>> S1, = host.plot(time,velocity, color = 'r')
>>>
>>> par1 = host.twinx()
>>> S2, = par1.plot(time, another_variable, color = 'g')
>>>
>>> plt.savefig('my_plot.png')
然后我得到了以正常大小保存的图形! 提前致谢!
【问题讨论】:
标签: python python-2.7 matplotlib