Idea for replacing facecolor='never' in `FeatureArtist`
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 https://github.com/SciTools/cartopy/pull/2323#discussion_r1500461295
I have been meaning to work on this but not got around to it so creating an issue before I forget completely!
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.
Hmmm. I think the relevant logic is in _set_mappable_flags. What happens if you pass facecolor="none", array=array?
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: https://github.com/SciTools/cartopy/pull/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()