Matplotlib: Colour Bar Resizing Image?
I'm assuming I have a really simple question, which has been driving me insane for the past hour. So, I am trying to produce a contour plot with the following axis lengths x=37,y=6
Solution 1:
It's the imshow
command that's changing the aspect ratio of the axes, not the colorbar.
imshow
assumes you want an aspect ratio of 1.0 so that a square in data coordinates will appear square (i.e. square pixels).
If you want it to behave like contour
, the just specify aspect='auto'
.
ax.imshow(z, cmap=cm.jet)
You should also remove the ax.matshow
line (or use it instead of imshow
). As it is, you'll have two images that partially overlap and hide each other.
If you do decide to use matshow
instead of imshow
, you'll need to specify aspect='auto'
for it, as well.
Post a Comment for "Matplotlib: Colour Bar Resizing Image?"