-
Notifications
You must be signed in to change notification settings - Fork 388
Closed
Description
To plot data into features, e.g. color each country according to data, it would be very helpful if FeatureArtist
would implement the ScalarMappable
interface: https://matplotlib.org/stable/api/cm_api.html#matplotlib.cm.ScalarMappable
So having set_array
, set_clim
, set_cmap
etc, so one can directly add the data and a colormap.
As a current workaround, one has to construct a colormap, norm and set the facecolors manually like this:
norm = Normalize(vmin=data.min(), vmax=data.max())
cmap = plt.get_cmap('inferno')
sm = ScalarMappable(cmap=cmap, norm=norm)
ax.add_feature(
feature,
facecolor=[cmap(norm(v)) for v in data],
)
fig.colorbar(sm, ax=ax)
when FeatureArtist
would be a ScalarMappable
, this should become a lot easiery, e.g. this should work:
artist = ax.add_feature(feature, array=data, cmap='inferno')
fig.colorbar(artist, ax=ax)