gonum / gonum/plot

Rethink Palette/Contour/Heatmap interface

Open
#20 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
3k
Forks
201
PR merge metrics
No merged PRs in 30d

Description

Palettes specify a list of colors. Strictly this is always a specific list, though may of the implemented palettes can create a long list of colors. These are being used at present to choose colors as part of Heatmaps and contours. In these cases, the z-axis values can be a real number, and a sort of interpolation function is being used to get the specific palette color. There are some special cases introduced, for example OverflowColor, which allow warning of specific colors.

In my mind, it's much better instead to have

```
// ColorFunc associates each float64 value with a color.Color
type ColorFunc func(float64) color.Color
```

A ColorFunc could use a palette as its underlying color choice. It could use a "threshholded palette", where it uses a palette for some intermediate range and uses warning colors outside of that range. There are many other possible uses, for example, returning a third warning color when the value is NaN, or having a grayscale image with a specific range of float64 returned as red to highlight their locations. It's much more powerful to have a function rather than just a palette with linear indexing, it's more composable because the special cases are located with the choice of color and not the choice of plotter, and (to me at least) it's more conceptually aligned with what's happening.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.