-
Notifications
You must be signed in to change notification settings - Fork 391
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
| fig, ax = plt.subplots(figsize=(9, 7.5), dpi=125, facecolor="white") | ||
| ax.set_facecolor("#AFCBBD") | ||
| ax = fig.add_subplot(111, projection=ccrs.LambertConformal(), frameon=False) | ||
| plt.setp(plt.gcf().get_axes(), xticks=[], yticks=[]) # no axes or labels |
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 you can call set directly on the axes you already have here.
| plt.setp(plt.gcf().get_axes(), xticks=[], yticks=[]) # no axes or labels | |
| ax.set(xticks=[], yticks=[]) # no axes or labels |
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.
| fig, ax = plt.subplots(figsize=(9, 7.5), dpi=125, facecolor="white") | ||
| ax.set_facecolor("#AFCBBD") | ||
| ax = fig.add_subplot(111, projection=ccrs.LambertConformal(), frameon=False) |
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.
Can you create the figure and then the single axes? I'm not sure why you need to two "ax" here.
| fig, ax = plt.subplots(figsize=(9, 7.5), dpi=125, facecolor="white") | |
| ax.set_facecolor("#AFCBBD") | |
| ax = fig.add_subplot(111, projection=ccrs.LambertConformal(), frameon=False) | |
| fig = plt.figure(figsize=(9, 7.5)) | |
| ax = fig.add_subplot(111, projection=ccrs.LambertConformal(), frameon=False) | |
| ax.set_facecolor("#AFCBBD") |
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.
| ) | ||
|
|
||
| # Make border symmetrical since default 'rc' file has asymmetric side pad | ||
| fig.tight_layout() |
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.
If you are trying to place things just right, we probably shouldn't call tight_layout at all since that adjusts all of the pads/trims things down.
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.
Fair enough, thanks for pointing this out. I will remove it in a feedback-response commit which I will push shortly.
|
|
||
| # Make border symmetrical since default 'rc' file has asymmetric side pad | ||
| fig.tight_layout() | ||
| fig.subplots_adjust(left=0.035, bottom=0.035, right=0.965, top=0.965) |
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.
Do you want to call add_axes() above to make an explicit placement in figure space?
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 will try playing around with use of add_axes, though from your previous comment it seems we don't want multiple axes so I am a bit confused as to how that fits with said plan - unless I use that to create the one and only axis. Would be useful if you can clarify?
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.
Sorry for the confusion, I was making various comments depending on which direction you were going to go. I agree with only one axes, how you put it in depends on what you want to do with it. If you want to explicitly place it or for it to take up the entire figure then I would manually place it with ax = fig.add_axes([0, 0, 1, 1], projection=GEOM_PROJ) (or subtract the margins you have above as necessary)
Co-authored-by: Greg Lucas <[email protected]>


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 this:
For reference, the original looks like this.