-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Corrected cax attributes of ImageGrid axes #3957
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
Conversation
cc @leejjoon This should probably be back-ported to 1.4.x |
@inclement Would you mind adding a test? Currently axes_grid has zero test coverage so anything is an improvement. If you are willing follow the directions here : http://matplotlib.org/devel/testing.html#writing-an-image-comparison-test |
Yes, I can certainly do that. |
Great! Ping me if you have any issues. |
I've added a simple test focused on this specific issue. |
I've just realised this PR doesn't correctly handle the cbar edge, confusing direction with cbar_location. I'll add a fix and tests for it tomorrow. |
Okay, I've fixed all the issues I'm aware of, assuming my test format is correct. |
The tests look good to me. I am not sure I fully understand the underlying code, I would like to get @leejjoon 's thoughts on this before merging. |
I think the test still needs to be white-listed |
@WeatherGod does that mean to add it to |
Yes, sorry I forgot to mention that before On Tue, Dec 30, 2014, 20:31 Alexander Taylor [email protected]
|
I merged the master branch into this one to fix a merge conflict that appeared, but now realise this was probably the wrong way to do it since it messes up the diff. Should I rebase a084e80 on the new master instead, or is there a better way? Sorry for the mistake, and thanks for the help! Edit: I reset the merge, but am still not sure if a rebase is the right way to resolve the merge conflict. |
d91c893
to
a084e80
Compare
Rebase and force push. Feature branches are OK to force push because they
|
a084e80
to
1ec309f
Compare
Could you also update the documentation on this function to explain the rules for sharing the color bars? Am I understanding that the colors that end up in the color bar are selected based on the order in which they are called (so the calls that look like no-ops in the final figure are actually just getting replaced)? re-milestoned as 1.5.x as this is seeming like a 'big' change to me now, but I am open to being (re)convinced it should be back-ported. |
The core of the problem is that (by default), each axis of the ImageGrid receives a I only used the overriding in the test because it demonstrates the problem well - without this PR being applied, the colorbars will be displayed on the wrong rows/columns or not displayed at all. Following this PR, the visible colorbar on each row/column is the most recent one called by a plotting axis in that row/column. As for backporting, I think this is probably a legitimate bug based on the documentation and existing code (which seems to imply that the |
|
||
|
||
@image_comparison(baseline_images=['imagegrid_cbar_mode'], | ||
remove_text=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we only need to test one format here. PNG is a good candidate.
@pelson Okay, I've set the test to png only |
Can you re-base it to expunge the pdf/svg files from history? |
b89d40c
to
4045a79
Compare
I finally worked out how to drive an interactive rebase and I think I've successfully removed the pdf and svg from history. |
Will it suffice to remove that image from the commit at which it was added but not change anything else, so the test will fail for those couple of commits (due to no reference image) but everything will be fixed by the later ones that modify the test and add the final image? |
Yes. We don't worry about tests passing on every commit, only on the On Fri Jan 30 2015 at 8:13:34 PM Alexander Taylor [email protected]
|
4045a79
to
53da33c
Compare
Okay, I think I've removed that image. |
Looks good to me. Would like feed back from @leejjoon before merging. |
BUG : Corrected cax attributes of ImageGrid axes
@inclement Thank you! |
Following the documentation, each axis of an ImageGrid should have a
cax
attribute pointing to the axis to be used for its colorbar. However, when the axes of a row or column share a colorbar, this attribute is not set correctly - colorbar axes are assigned as if every axis has its own colorbar, so most of thecax
attributes are not visible axes, and the axes do not match the correct row or column.This PR changes the behaviour to correctly associate axes of a row/column with the colorbar at the end of that row/column.
Example code demonsrating the problem is:
Before this patch, the top-right colorbar will be empty while the bottom-right colorbar will show colours from one of the top-row plots. After this patch, the colorbars updated are those in the correct row/column to match the axis whose
cax
attribute was accessed.This would be a breaking change for any users currently using the workaround of accessing the cax attributes or cbar_axes dircetly in order of their creation, which corresponds to the order in which they are visible. I'm not sure what the matplotlib policy is on such changes, let me know if it is inappropriate!
Edit: added results of the above script
before:

and after:
