如何使用 pylab 绘制没有边框的数据
使用 pylab,我想将没有轴或边框的数据绘制到 png 文件中。在下面的代码中,我仍然得到数据左侧和右侧的边框。
import pylab
scores = [[ 82.,78., 71.5, 76., 79.5, 77., 73.5, 70.5, 74., 74.5 ],
[ 79. , 75.75, 71., 76., 78.25, 73.25, 72.25 ,73.25, 74.75, 73.5 ],
[ 77., 75., 70.5, 73. , 77., 73.5, 71.75, 75.25, 76.75, 74. ],
[ 76., 74.75, 72.5, 72.25 ,75.25, 76.5, 73.5, 73., 75.25, 75.75],
[ 75., 72.5, 72.25, 74.5, 73.25, 73.25, 74.5, 73.25, 73.5, 76.5 ],
[ 74.5, 72., 69.5, 73.25, 73.75, 72., 76.75, 77., 74.25, 76.5 ],
[ 72.5, 73.75, 72.75, 75.75, 78., 76.75, 77.75, 78.75, 77.25, 74. ],
[ 74.5, 74.25, 74.75, 78.75, 80.75, 79.25, 74.5, 75., 76.25, 73. ],
[ 75.5, 71.5, 71.75, 78.75, 80.25, 77.5, 75., 73.25, 72.25, 72.75],
[ 77.5, 74.5, 72., 77.75, 78.25, 74., 76.75, 75.75, 74.25, 73. ]]
fig = pylab.figure()
ax = fig.add_subplot(111)
ax.xaxis.set_ticklabels([None])
ax.yaxis.set_ticklabels([None])
ax.xaxis.set_ticks([None])
ax.yaxis.set_ticks([None])
ax.imshow(scores,vmin=0, vmax=100, origin='lower')
pylab.savefig('output.png',bbox_inches='tight', pad_inches=0)
Using pylab, I want to plot just the data with no axes or borders to a png file. In code below, I still get borders to the left and right of the data.
import pylab
scores = [[ 82.,78., 71.5, 76., 79.5, 77., 73.5, 70.5, 74., 74.5 ],
[ 79. , 75.75, 71., 76., 78.25, 73.25, 72.25 ,73.25, 74.75, 73.5 ],
[ 77., 75., 70.5, 73. , 77., 73.5, 71.75, 75.25, 76.75, 74. ],
[ 76., 74.75, 72.5, 72.25 ,75.25, 76.5, 73.5, 73., 75.25, 75.75],
[ 75., 72.5, 72.25, 74.5, 73.25, 73.25, 74.5, 73.25, 73.5, 76.5 ],
[ 74.5, 72., 69.5, 73.25, 73.75, 72., 76.75, 77., 74.25, 76.5 ],
[ 72.5, 73.75, 72.75, 75.75, 78., 76.75, 77.75, 78.75, 77.25, 74. ],
[ 74.5, 74.25, 74.75, 78.75, 80.75, 79.25, 74.5, 75., 76.25, 73. ],
[ 75.5, 71.5, 71.75, 78.75, 80.25, 77.5, 75., 73.25, 72.25, 72.75],
[ 77.5, 74.5, 72., 77.75, 78.25, 74., 76.75, 75.75, 74.25, 73. ]]
fig = pylab.figure()
ax = fig.add_subplot(111)
ax.xaxis.set_ticklabels([None])
ax.yaxis.set_ticklabels([None])
ax.xaxis.set_ticks([None])
ax.yaxis.set_ticks([None])
ax.imshow(scores,vmin=0, vmax=100, origin='lower')
pylab.savefig('output.png',bbox_inches='tight', pad_inches=0)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这应该可以做到。没有为我显示任何轴。我所做的只是添加frameon=False。
This should do it. Doesnt show any axises for me. All I did was add frameon=False.