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

Idea for replacing facecolor='never' in FeatureArtist #2448

Open
rcomer opened this issue Oct 5, 2024 · 3 comments
Open

Idea for replacing facecolor='never' in FeatureArtist #2448

rcomer opened this issue Oct 5, 2024 · 3 comments
Labels
API Change Denotes issues or PRs that change the interface Component: matplotlib

Comments

@rcomer
Copy link
Member

rcomer commented Oct 5, 2024

Another solution to that might be to have a flag on the feature that says "these are edges" and override set_color to only set the edgecolor in that case. This would make us more consistent with LineCollection which will still allow you to explicitly set facecolor if you really want. This might also work as a solution for #1782 - though there we probably need to account for some geometries being edges and some not.

Originally posted by @rcomer in #2323 (comment)

I have been meaning to work on this but not got around to it so creating an issue before I forget completely!

@rcomer rcomer added Component: matplotlib API Change Denotes issues or PRs that change the interface labels Oct 5, 2024
@greglucas
Copy link
Contributor

I just ran into this again where I wanted to use the new Choropleth style feature artist on a collection of LineStrings to automatically color them based on value and my linestrings weren't showing up because they need to be colored by edges and it apparently also doesn't work to pass in edgecolors=array, so I don't see a way to currently workaround this without fixing the underlying issue.

@rcomer
Copy link
Member Author

rcomer commented Oct 9, 2024

Hmmm. I think the relevant logic is in _set_mappable_flags. What happens if you pass facecolor="none", array=array?

@greglucas
Copy link
Contributor

Thanks @rcomer! I was missing the facecolor="none" and now it works as expected. We do have a PR potentially trying to automatically do this for users too it looks like: #1790

Something to automate this for Line-like geometries would be nice from a user perspective ;)

import matplotlib.pyplot as plt
import numpy as np
import cartopy

import shapely

x = np.arange(10)

lines = [shapely.LineString([(i, 0), (i + 10, 10)]) for i in range(10)]

ax = plt.subplot(111, projection=cartopy.crs.PlateCarree())
ax.add_geometries(lines, cartopy.crs.PlateCarree(), facecolor="none", array=x, cmap='viridis')
ax.coastlines()
ax.set_extent([0, 20, 0, 20])

plt.show()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Change Denotes issues or PRs that change the interface Component: matplotlib
Projects
None yet
Development

No branches or pull requests

2 participants