How can I plot just the data with no borders using pylab
Usin开发者_如何学Pythong 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)
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(frameon=False)
ax_size = [0,0,1,1]
fig.add_axes(ax_size)
pylab.imshow(scores,vmin=0, vmax=100, origin='lower')
pylab.axis('off')
## As you noted.
pylab.savefig('output.png',bbox_inches='tight', pad_inches=0)
This should do it. Doesnt show any axises for me. All I did was add frameon=False.
精彩评论