문제

I want to plot something row after row, because each row c[row] has not the same length. Here is the code that I use. Each row is mapped/rendered to the interval [0,1], regardless if c[row] had 2,4, or 100 elements.

 #vmin = ...
 #vmax = ...
 gca().set_autoscale_on(False)
 for row in range(len(c)):
   imshow([c[row]], interpolation = 'nearest', vmin = vmin, vmax = vmax, extent = [0, 1, row*1.0/len(c), (row+1.0)/len(c)])

It works, but the aspect ratio is always square! I cannot add aspect= something else because as imshow is called each time for a line only!

How can I get a rectangle ratio (example 2:1 instead of square 1:1)

(Or maybe there is a better idea to plot line after line rather than imshow?)

도움이 되었습니까?

해결책

You just need to set the aspect ratio of the axes

ax = gca()
ax.set_aspect(2)
plt.draw()
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top