【发布时间】:2018-03-20 14:21:41
【问题描述】:
使用matplotlib.pyplot,我想创建一个条形图,并将其保存到一个没有坐标轴、边框和额外空白的图像中。 Save spectrogram (only content, without axes or anything else) to a file using Matloptlib 的答案以及所有链接的问题和各自的答案似乎不适用于条形图。
到目前为止,我得到了:
import matplotlib.pyplot as plt
fig,ax = plt.subplots(1)
fig.subplots_adjust(left=0,right=1,bottom=0,top=1)
fig.patch.set_facecolor('xkcd:mint green')
ax.set_facecolor('xkcd:salmon')
ax.axis('off')
ax.bar(1,1,1,-1,alpha=1, align='center', edgecolor='black')
ax.bar(2,1,1,-2,alpha=1, align='center', edgecolor='black')
ax.axis('off')
fig.savefig('test.png', dpi=300, frameon='false', pad_inches=0.0,bbox_inches='tight')
这三个问题:
- 左侧、顶部和右侧还有一些剩余的空白。
- 该图似乎在底部被切开,因为下部条的底线比其他条更细。
- 纵横比应该是 1:1,而且似乎是关闭的。
【问题讨论】:
标签: python matplotlib