2

I saw lots of examples explaining how to save plots in a different size, but none of them was using host_subplots. I would like to save the graph as it looks like when I maximize the window which the plot appears at first. The following block is a shorter version of what I've been doing:

>>> 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')

And then I got the figure saved in a normal size! Thanks in advance!

4

1 回答 1

5

host_subplot不应改变处理图形大小的方式。plt.figure(figsize=[8,10])您可以在创建之前设置图形大小host

于 2013-06-19T19:38:28.337 回答