我最近升级到了新的matplotlib 2.0.2。新的默认颜色很棒,但现在我的绘图尺寸被忽略了。即我预计的情节是8.2×10厘米,dpi为600.我的情节宽度正确,但高度不正确。
任何人都可以帮忙指出我在哪里错了吗?示例代码如下:
from matplotlib.pylab import *
from numpy import *
# made up data
z = linspace(0.0,1.0, 100)
a = linspace(0.0,2.0, 100)
b = linspace(0.5,2.1, 100)
# fig size and positioning
figx = 8.2 # width of image in cm
figy = 10.0 # height of image in cm
x0 = 0.15 # left edge of plot (between 0-1)
y0 = 0.15 # bottom edge of plot (between 0-1)
xw = 0.7 # width of plot (between 0-1)
yh = 0.7 # height of plot (between 0-1)
# Draw plot
figure(figsize=(figx/2.54,figy/2.54))
axes([x0,y0,xw,yh])
plot(a,z, label = 'label1')
plot(b,z, label = 'label2')
xlabel('x label goes here', labelpad=1)
ylabel('y label goes here', labelpad=1)
legend(frameon=False)
savefig('test.png', dpi=600)
close('all')