-
Notifications
You must be signed in to change notification settings - Fork 89
Description
Introduce colormaps and a default colormap.
There are two principal uses of colormaps:
- Heatmaps
- Picking plot item colors (lines, markers, etc.)
Definition
Let's define colormap as a mapping from the unit interval to RGB space (Color32).
Within this unit interval, there are at least two "anchor" points, for
There can be more anchors at distinct
Interpolation
The colormap interpolates between the anchor points. The interpolation can be specified as one of:
- RGB
- HSL / HSV / HSB
- CIELAB
- LCH
- OKLab / OKLCH
Sampling
These can be either "finite" to cycle through the colormap, or "infinite", covering the unit interval.
The finite case
The "infinite" case can use
- Sobol / Kronecker/ Van der Corput sequence. Exploration with chatgpt
Principal uses
1. Heatmaps
One has to first normalize the input data to unit interval to get the color. This normalization will be typically linear or logarithmic, for on a given segment (for min/max over displayed data).
For coloring values (i.e. the heatmap implementation), one has to normalize the input data to unit interval before getting the color.
2. Plot item colors
We use the sampling algorithm here and get a color via a next call.
Colormap API
newwith vec of Color32 anchor points -- make them uniformly distributed. At least 2 points! Makes sampling to be finite N by default.new_with_positionsallow pass vec of [Color32, t=f32] values. Check ordering, and boundary points! Makes sampling to bewith_interpolation- setwith_sampling- specifyget(&self, t: f32) -> Color32:next(&mut self, id: egui::Id) -> Color32:- use an internal counter to get the next color, by using specified sampling. Use the passedidto make sure the assigned colors are stable.
Integration
Specify colormap in the Plot builder. Do not require plot lines/points to specify colors, but they can override them.
Demo
Allow changing the color maps and sampling, show both a plot with some lines/points (left), and a heatmap (right).