我需要制作一个矢量图,并且希望只看到矢量而没有坐标轴、标题等其他元素,这是我尝试实现的方式:
pyplot.figure(None, figsize=(10, 16), dpi=100)
pyplot.quiver(data['x'], data['y'], data['u'], data['v'],
pivot='tail',
units='dots',
scale=0.2,
color='black')
pyplot.autoscale(tight=True)
pyplot.axis('off')
ax = pyplot.gca()
ax.xaxis.set_major_locator(pylab.NullLocator())
ax.yaxis.set_major_locator(pylab.NullLocator())
pyplot.savefig("test.png",
bbox_inches='tight',
transparent=True,
pad_inches=0)
尽管我努力想让图像大小为1000 x 1600,但最终得到的只有775 x 1280。如何使其达到期望的尺寸呢?谢谢。
更新:所提供的解决方案有效,但在我的情况下,我还必须手动设置轴限制。否则,matplotlib无法找到“紧密”的边界框。