Closed ZarulHanifah closed 5 years ago
The key is the explicit vmin=0, vmax=3
in the call to imshow
.
Because we've set vmin and vmax, it doesn't matter which AxesImage
instance (im
) we base the colorbar on. Each im
object has the same range, as it's not calculated from the data at all. We've set it independently of the input data by specifying vmin=0, vmax=3
.
Hope that helps clarify what's going on. Manual scaling with vmin
/vmax
is the key point that example is trying to communicate, so if it wasn't clear to you, it likely wasn't clear to other folks as well.
Perhaps a bit more explanation should be added to that example in the tutorial?
Thank you very much joferkington!
Hello matplotlib developers,
I was watching the Youtube recording: Anatomy of Matplotlib from SciPy 2018, and I have a question about AnatomyOfMatplotlib/solutions/2.2-vmin_vmax_imshow_and_colorbars.py
From line 17 to 18...
for ax, data in zip(axes, [data1, data2, data3]):
im = ax.imshow(data, vmin=0, vmax=3, interpolation='nearest')
I am assuming data3 has bigger values, followed by data2 and data2, since data3 is multiplied by 3. Suppose if I switch the order of the list in line 17 from:
for ax, data in zip(axes, [data1, data2, data3]):
to:
for ax, data in zip(axes, [data3, data2, data1]):
So, the last im object would data1 which has a 10 by 10 array with max value of 1. Since we are giving the last im object to make the colorbar, would that mean the range color bar spans from 0 to around 1? Or does matplotlib somehow manage to look at all three plotted imshows and perceive that the maximum value amongst the three imshows is around 3?
Thank you!