You just need to set the aspect ratio of the axes
ax = gca()
ax.set_aspect(2)
plt.draw()
Вопрос
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()