-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Updated custom_projection_example.py to work with v1.2 and newer #1579
Updated custom_projection_example.py to work with v1.2 and newer #1579
Conversation
I should have added this information here instead of on the mailing list. At any rate, here's the rationale for the changes, beyond simply fixing the example: At some point It's certainly makes things more logical and consistent, but it changed what methods need to be overridden when subclassing It looks like Phil caught the changes for the polar and geo projections, but the custom projection example was never updated. This led to the example failing for newer (1.2.0 and master) versions. However, it's worth elaborating on the changes to the With versions 1.1.x and older, one had to directly implement a With versions 1.2.x and newer, the preferred way appears to be to implement If you implement the non-affine portion directly in the On the other hand, for compatibility with versions 1.1 and older, you have Therefore, now one needs to explicitly implement both the Similarly, one needs to implement both the |
# Once again, for compatibility with matplotlib v1.1 and older, we need | ||
# to explicitly override ``transform_path``. With v1.2 and newer, only | ||
# overriding the ``transform_path_non_affine`` method is sufficient. | ||
transform_path = transform_path_non_affine |
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.
We could do a version specific override here. Something like:
if matplotlib.__version__ < '1.2':
transform_path = ...
...
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.
Good point! Also a version-specific conditional would potentially be more future-proof, as well as "stretching the legs" of the new functionality. I'll add that here directly.
Thanks for doing this - much appreciated! I have commented that we might consider applying the compatibility code only if the version requires it, that way we are stretching the legs of the new functionality for newer versions, whereas we can still run the code for older. What do you think? |
Other than that 👍 |
P.S. Once we are happy with this, we will want to apply it to the v1.2.x branch. |
Thanks for catching this. +1 (and I agree with all of @pelson's comments). |
I agree, the version conditional makes the intent more clear, in case someone doesn't read the comments closely. Also, it's arguably more future-proof than re-implementing the default |
Updated custom_projection_example.py to work with v1.2 and newer
Thanks @joferkington - keep up the great work! |
Thanks! |
Updated custom_projection_example.py to work with v1.2 and newer
Cherry-picked to v1.2.x and will update the online docs shortly. |
custom_projection_example.py
is currently broken with matplotlib v1.2.x.Compare the custom_projection_example.py run with matplotlib 1.1
with the custom_projection_example.py run with matplotlib 1.2