Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imshow color bar #28

Closed
ZarulHanifah opened this issue Nov 10, 2018 · 2 comments · Fixed by #31
Closed

imshow color bar #28

ZarulHanifah opened this issue Nov 10, 2018 · 2 comments · Fixed by #31

Comments

@ZarulHanifah
Copy link

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!

@joferkington
Copy link
Collaborator

joferkington commented Nov 10, 2018

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?

@ZarulHanifah
Copy link
Author

Thank you very much joferkington!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants