-
Notifications
You must be signed in to change notification settings - Fork 389
DOC: new example, recreation of The Simpsons Monorail Map #2585
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
base: main
Are you sure you want to change the base?
DOC: new example, recreation of The Simpsons Monorail Map #2585
Conversation
|
Hi @greglucas, thanks for your helpful review. I committed one one-line trivial suggestion and addressed the other comments in a few new commits, so this is now ready for re-review. For context, to clarify relating to the feedback and my response in those commits:
|
|
@sadielbartholomew the unrelated doc failure is now fixed on |
| ) | ||
|
|
||
| # Now add the location labels. The general approach is that covered in | ||
| # the 'Map tile acquisition' Catopy example, including the comment below. |
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.
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.
OK, so what should I do for my PR code, if anything?
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 recommend using annotate, as it should simplify the code (and not make use of the private _as_mpl_transform method).
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.
Ah, I see now. I used the PR you referenced as a guide on what to do and updated this in 1468b5c. That part of the logic indeed looks much cleaner and simpler now, thanks!
This point should now be resolved but I'll leave you to mark it as such.
Co-authored-by: Greg Lucas <[email protected]>
Co-authored-by: Greg Lucas <[email protected]>
a8baf8a to
701ca15
Compare
|
Have addressed new feedback from @rcomer (awaiting one clarification RE #2585 (comment)) and force pushed after rebasing onto main. |
|
Sorry I missed @rcomer's new comment a few weeks ago, but I have now addressed that point - see comment on the thread above. As far as I am concerned, all feedback has been addressed so this is ready to merge (else ready for another round of review). Thanks. |
| """ | ||
|
|
||
| import matplotlib.pyplot as plt | ||
| from matplotlib.transforms import offset_copy |
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.
| from matplotlib.transforms import offset_copy |
Unused import
|
|
||
| import cartopy.crs as ccrs | ||
| import cartopy.io.shapereader as shpreader | ||
| from matplotlib.patches import Rectangle |
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.
| from matplotlib.patches import Rectangle |
Unused import
| GEOM_PROJ = ccrs.PlateCarree() | ||
| # Not real places, so locations pulled from location on map in still image | ||
| # First value 2-tuple is the dot placemap location, second is where to write | ||
| # the text label relative to that dot, to best match the map from the show. |
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.
Add a comment that the integer is text rotation?
| LOCATIONS_TO_PLOT = { | ||
| "Ogdenville": [(-111.8, 35.5), (1.5, -2.2), -6], | ||
| "North\nHaverbrook": [(-99.0, 43.5), (2.8, -0.5), -1], | ||
| "Brockway": [(-80.4, 33.6), (-3.4, -1.5), 3], |
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 guess the second tuple here is expressed in degrees. If it was expressed in points then annotate could take xy=loc_coords, xytext=rel_text_pos.
Feel free to push back if there is a reason not to do that!
| verticalalignment="center", | ||
| style="italic", | ||
| bbox=dict(facecolor="#A5B5CE"), | ||
| ) |
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.
Optional: could consider using AnchoredText here if you want the legend text right in the corner.
Rationale
For fun (and love of said TV Series), I have recreated the Monorail Map from The Simpsons using Cartopy - the challenge was to get as close to likeness as I could using the standard Python visualisation ecosystem - matplotlib etc, in a small-ish script, and Cartopy made this simple.
Whist I did this mostly with the motivation of making high-res print outs for myself, I think it would make a good example for your examples gallery. As I summarise in the top-level docstring:
Moreover, other vis libraries with examples galleries have humorous examples - notably the XKCD examples - so I think i is nice to add (another) one to the Cartopy examples gallery.
From other PRs adding new examples I have found from a quick search, it seems that I just need to add the new script in the appropriate place under 'cartopy/examples/` and the relevant subdirectory to categorise - I think 'miscellanea' is most suitable, but happy to move it if you wish.
Please let me know if you would like me to adjust it in any way if you would accept it for the gallery - either codewise or output-wise.
Implications
A new example recipe will be added to the docs and maybe somebody will find it useful and/or amusing. 🙂
Notes
The output (with Python 3.12) is:
Original from when PR opened:
Updated output after feedback response and tweaks, at a8baf8a:
For reference, the original looks like this.