pub struct ContourConfig {
pub levels: Vec<f64>,
pub line: DataLineStyleConfig,
pub per_level_color: Option<Vec<Color>>,
pub labels: Option<ContourLabelConfig>,
}Expand description
Contour lines over a field.
Fields§
§levels: Vec<f64>The levels to draw, in data units, with at most
MAX_CONTOUR_LEVELS entries. An explicit list only — there is no
“auto” variant, because a level set inferred at draw time is a value the
config does not contain. A helper computes levels and writes them here.
line: DataLineStyleConfig§per_level_color: Option<Vec<Color>>Per-level colours, indexed by level. None means every level is
line.line_color — colours are not derived from the colormap here. A
helper that wants colormap colours computes them and writes them in.
labels: Option<ContourLabelConfig>Implementations§
Source§impl ContourConfig
impl ContourConfig
Sourcepub fn nice_levels(
axis: &AxisOptions,
target_count: usize,
) -> Result<Vec<f64>, TickError>
pub fn nice_levels( axis: &AxisOptions, target_count: usize, ) -> Result<Vec<f64>, TickError>
About target_count round levels inside a colourbar’s z range.
There is no Auto level variant, and this is why there does not need to
be one: the levels a chart draws are always the ones in
Self::levels, and a caller who wants them chosen for it calls this and
stores the answer. What is drawn is then still exactly what the config
says.
Levels are strictly inside the range. One sitting exactly on
axis.min or axis.max coincides with the field’s outer boundary or has
no visible coverage at
all, and it would also make the banded fill’s n + 1 bands come out
wrong by one.
The spacing is the axis machinery’s own: compute_nice_ticks picks it,
and the walk anchors to absolute multiples of it, so the levels are round
numbers even when the range ends are not. A logarithmic colourbar gets
decades from the same call, with no separate rule here.
Sourcepub fn set_nice_levels(
&mut self,
axis: &AxisOptions,
target_count: usize,
) -> Result<(), TickError>
pub fn set_nice_levels( &mut self, axis: &AxisOptions, target_count: usize, ) -> Result<(), TickError>
Replace Self::levels with Self::nice_levels.
Self::per_level_color is left alone: a colour list that no longer
lines up with the new levels falls back to Self::line’s colour per
level rather than being silently thrown away. Call
Self::set_colormap_colors after this to re-derive it.
Sourcepub fn set_colormap_colors(&mut self, bar: &ColorBarOptions)
pub fn set_colormap_colors(&mut self, bar: &ColorBarOptions)
Colour every level by where it sits on the colourbar’s ramp.
The helper the per_level_color doc means by “a helper that wants
colormap colours computes them and writes them in” — the field’s fill and
the lines over it then agree about what a value looks like, because both
go through ColorBarOptions::color_for_z. A level the ramp cannot place
takes nan_color, the same as a cell with that value.