SciNim / nim-plotly

plotly wrapper for nim-lang
https://scinim.github.io/nim-plotly/
MIT License
173 stars 15 forks source link

Add support for custom color maps, some predefined ones #52

Closed Vindaar closed 4 years ago

Vindaar commented 4 years ago

I recently wanted to compare Viridis with Plasma for a plot and change the colormap to be white as the zero value. Thought I'd clean this up and add support for easier handling of custom colormaps.

Instead of playing around with the JsonNode after converting to PlotJson (or serializing), one can either assign one of the predefined custom colormaps:

each with and without zero value as white

The normal colormap field has to be set to Custom for the custom map to be considered.

Alternatively the colormap sugar function can be used on a Plot[T] object. This is more convenient imo. One can hand one of:

See the fig20 example and the test case for explicit usage.

Vindaar commented 4 years ago

Renamed the fields.