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

DOC: add example showing FeatureArtist is a ScalarMappable #2340

Merged
merged 1 commit into from
Mar 7, 2024

Conversation

rcomer
Copy link
Member

@rcomer rcomer commented Mar 6, 2024

Rationale

Since #2323 FeatureArtist is a ScalarMappable so we can colour geometries using a data array. I don't think this functionality is very discoverable so here is an example. Bikeshedding suggestions welcome!

Implications

@rcomer
Copy link
Member Author

rcomer commented Mar 6, 2024

Renders like this

Copy link
Contributor

@greglucas greglucas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, a nice succinct example to demo it. Feel free to merge yourself with or without my minor suggestions.


# Plot the geometries coloured according to population estimate.
art = ax.add_geometries(geometries, crs=ccrs.PlateCarree(),
array=population_estimates, cmap='YlGnBu', norm='log')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set a lower limit of 1 million to get a little more color variation?

Suggested change
array=population_estimates, cmap='YlGnBu', norm='log')
array=population_estimates, cmap='YlGnBu', norm='log', vmin=1e6)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mappable won't take vmin so we have to pass it to the LogNorm. I think that's OK and I had already been wondering about limiting the range, so 👍

--------------------------------

This example shows how to colour geometries based on a data array. This
functionality is available since Cartopy 0.23.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to do a .. since: or something to automatically tag this with sphinx-gallery. I like that you put this in there to let people know when it came in!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if there is but I am far from an expert in sphinx and sphinx-gallery. Over at matplotlib/matplotlib#27292 Hannah was advocating using sphinx tags for that sort of thing.

@rcomer
Copy link
Member Author

rcomer commented Mar 7, 2024

And the tests are broken again :-(

@rcomer
Copy link
Member Author

rcomer commented Mar 7, 2024

The test failure seems to be coming from deep in owslib. Anyway it's clearly not caused by this PR so I'm going to merge.

@rcomer rcomer merged commit 0fd1de7 into SciTools:main Mar 7, 2024
9 of 22 checks passed
@rcomer rcomer deleted the fa-cm branch March 7, 2024 17:04
@rcomer rcomer added this to the Next Release milestone Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants