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
Some colormaps in the get_colormaps
dictionary are not Colormap instances
#1487
Comments
fine by me |
@djhoese I can have a look early next week. |
Here is a copy of the raw dictionary:
And visuals like |
I've a suggestion. If the colormap is not in the if (cmap not in _colormaps) and has_mpl:
from matplotlib import cm
# Get the list of implemented colormaps in Matplotlib :
full_mpl_cmaps = list(cm.datad.keys()) + list(cm.cmaps_listed.keys())
if cmap not in full_mpl_cmaps:
raise ValueError("%s colormap not in matplotlib" % cmap)
sc = cm.ScalarMappable(cmap=cmap)
x = np.arange(256)
cmap_vec = np.array(sc.to_rgba(x, alpha=1.))
return Colormap(cmap_vec) |
@EtienneCmb Now that vispy supports texture-based colormaps this should be a lot easier. If you want to make a pull request for this I'd be ok with that. If mpl colormaps need more than 256 colors we can do that too (ex. viridis). |
If I recall correctly this was added by @larsoner. In
vispy/color/colormap.py
there is a_colormaps
dictionary that can be accessed via the publicget_colormaps()
. However, as a user, I expect this dictionary to map colormap names to colormap instances, some of these values though are colormap classes or functions. For example,cubehelix -> CubeHelixColormap
andsingle_hue -> _SingleHue
. This is "worked around" by having theget_colormap
function create these colormaps with optional kwargs passed to the class.I'm not a huge fan of this so unless someone can argue for this behavior I would like to propose that we replace these non-instance colormaps with basic instances or remove them from the colormap dictionary returned from
get_colormaps
.The text was updated successfully, but these errors were encountered: