diff --git a/gallery/bitcoin.png b/gallery/bitcoin.png
index fa3e9ee..777e415 100644
Binary files a/gallery/bitcoin.png and b/gallery/bitcoin.png differ
diff --git a/gallery/bode_rlc.svg b/gallery/bode_rlc.svg
index 49adf0f..cf87283 100644
--- a/gallery/bode_rlc.svg
+++ b/gallery/bode_rlc.svg
@@ -2,7 +2,7 @@
-
+
diff --git a/gallery/bode_rlc_macchiato.png b/gallery/bode_rlc_macchiato.png
index 1253a94..a2bf612 100644
Binary files a/gallery/bode_rlc_macchiato.png and b/gallery/bode_rlc_macchiato.png differ
diff --git a/gallery/bode_rlc_mocha.png b/gallery/bode_rlc_mocha.png
index 3b2e2eb..184c0bb 100644
Binary files a/gallery/bode_rlc_mocha.png and b/gallery/bode_rlc_mocha.png differ
diff --git a/gallery/bouncing_ball.png b/gallery/bouncing_ball.png
index 1b4a733..7a13bf6 100644
Binary files a/gallery/bouncing_ball.png and b/gallery/bouncing_ball.png differ
diff --git a/gallery/gauss.png b/gallery/gauss.png
index 5541b4e..100e570 100644
Binary files a/gallery/gauss.png and b/gallery/gauss.png differ
diff --git a/gallery/iris.png b/gallery/iris.png
index c3af101..1e3fa12 100644
Binary files a/gallery/iris.png and b/gallery/iris.png differ
diff --git a/gallery/sine.png b/gallery/sine.png
index a7c0883..9a659d3 100644
Binary files a/gallery/sine.png and b/gallery/sine.png differ
diff --git a/gallery/stars.png b/gallery/stars.png
new file mode 100644
index 0000000..805f6b7
Binary files /dev/null and b/gallery/stars.png differ
diff --git a/src/des.rs b/src/des.rs
index 10fda1f..27814d1 100644
--- a/src/des.rs
+++ b/src/des.rs
@@ -14,7 +14,7 @@ pub mod series;
pub use annot::Annotation;
pub use axis::Axis;
-pub use colorbar::{ColorBar, ColorBarPos};
+pub use colorbar::ColorBar;
pub use figure::{FigLegend, Figure};
pub use legend::Legend;
pub use plot::{Plot, PlotLegend, Subplots};
diff --git a/src/des/cmap.rs b/src/des/cmap.rs
index e1fc36a..56f3e06 100644
--- a/src/des/cmap.rs
+++ b/src/des/cmap.rs
@@ -1,6 +1,7 @@
//! A module for defining color maps that can be used in the design of plots to map scalar values to colors.
use crate::color::Rgb8;
+use crate::des::axis;
/// Describes how to interpolate between colors in a color map, either in linear RGB or perceptual color space.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
@@ -21,6 +22,7 @@ pub struct LerpColorMap {
end: Rgb8,
stops: Vec<(f32, Rgb8)>,
data_range: Option<(f64, f64)>,
+ locator: Option,
}
impl LerpColorMap {
@@ -31,6 +33,7 @@ impl LerpColorMap {
start,
end,
data_range: None,
+ locator: None,
stops: Vec::new(),
}
}
@@ -45,8 +48,11 @@ impl LerpColorMap {
self
}
- /// Set the range of scalar values that this color map maps to, as (min, max).
- pub fn with_data_range(mut self, range: (f64, f64)) -> Self {
+ /// Force the range of scalar data values that this color map maps to, as (min, max).
+ ///
+ /// By default, the colormap will map the range of data values in the plot, but this can be overridden with this method.
+ /// Use this if only a specific range of data are meaningful to map to colors.
+ pub fn force_data_range(mut self, range: (f64, f64)) -> Self {
assert!(
range.0.is_finite() && range.1.is_finite(),
"Color map data range must be finite"
@@ -59,6 +65,14 @@ impl LerpColorMap {
self
}
+ /// Force the ticks of colorbar mapping this colormap to be located according to the given locator.
+ /// By default, the locator is automatic, but this can be overridden with this method.
+ /// Use this if you want to have specific control over the ticks of the colorbar, for example to place them at specific data values.
+ pub fn force_ticks_locator(mut self, locator: axis::ticks::Locator) -> Self {
+ self.locator = Some(locator);
+ self
+ }
+
/// Get the interpolation method used by this color map.
pub fn method(&self) -> LerpMethod {
self.method
@@ -79,11 +93,16 @@ impl LerpColorMap {
&self.stops
}
- /// Get the range of scalar values that this color map maps to, if it has one.
+ /// Get the range of scalar values that this colormap is forced to map to, if it has one.
/// If None, the color map is assumed to map the range of data values in the plot.
- pub fn data_range(&self) -> Option<(f64, f64)> {
+ pub fn forced_data_range(&self) -> Option<(f64, f64)> {
self.data_range
}
+
+ /// Get the ticks locator that this colormap is forced to use for its colorbar, if it has one.
+ pub fn forced_ticks_locator(&self) -> Option<&axis::ticks::Locator> {
+ self.locator.as_ref()
+ }
}
impl From<(LerpMethod, &[Rgb8])> for LerpColorMap {
@@ -154,8 +173,14 @@ pub fn stellar() -> LerpColorMap {
.with_stop(stop_for_temp(8000.0))
.with_stop(stop_for_temp(9000.0))
.with_stop(stop_for_temp(10000.0))
- .with_stop(stop_for_temp(12000.0))
- .with_data_range((MIN_TEMP, MAX_TEMP))
+ .with_stop(stop_for_temp(12500.0))
+ .force_data_range((MIN_TEMP, MAX_TEMP))
+ .force_ticks_locator(axis::ticks::Locator::List(
+ vec![
+ 1000.0, 2000.0, 3000.0, 4000.0, 5000.0, 6500.0, 8000.0, 10000.0, 12500.0, 15000.0,
+ ]
+ .into(),
+ ))
}
/// The famous "viridis" color map from matplotlib
diff --git a/src/des/colorbar.rs b/src/des/colorbar.rs
index 95c9b44..e23ee98 100644
--- a/src/des/colorbar.rs
+++ b/src/des/colorbar.rs
@@ -1,4 +1,5 @@
//! Color bar configuration
+use crate::des::axis;
use crate::style::{defaults, theme};
use crate::text;
@@ -12,7 +13,7 @@ impl Default for TitleProps {
/// Position of a color bar relatively to the plot
#[derive(Debug, Default, Clone, Copy)]
-pub enum ColorBarPos {
+pub enum Pos {
/// Position the color bar above the plot area
Top,
/// Position the color bar to the right of the plot area (default)
@@ -48,18 +49,19 @@ impl Default for TicksFont {
/// ColorBar configuration for a plot
#[derive(Debug, Clone)]
pub struct ColorBar {
- pos: ColorBarPos,
+ pos: Pos,
width: f32,
title: Option,
ticks_font: TicksFont,
border: Option,
+ locator: axis::ticks::Locator,
margin: f32,
}
impl Default for ColorBar {
fn default() -> Self {
Self {
- pos: ColorBarPos::default(),
+ pos: Pos::default(),
width: defaults::COLORBAR_WIDTH,
title: None,
ticks_font: TicksFont::default(),
@@ -69,6 +71,7 @@ impl Default for ColorBar {
pattern: Default::default(),
opacity: None,
}),
+ locator: axis::ticks::Locator::Auto,
margin: defaults::COLORBAR_MARGIN,
}
}
@@ -76,7 +79,7 @@ impl Default for ColorBar {
impl ColorBar {
/// Create a new color bar with the specified position
- pub fn new(pos: ColorBarPos) -> Self {
+ pub fn new(pos: Pos) -> Self {
Self {
pos,
..Default::default()
@@ -107,6 +110,12 @@ impl ColorBar {
self
}
+ /// Set the ticks locator and return self for chaining
+ pub fn with_ticks_locator(mut self, locator: axis::ticks::Locator) -> Self {
+ self.locator = locator;
+ self
+ }
+
/// Set the margin between the color bar and the plot area and return self for chaining
pub fn with_margin(mut self, margin: f32) -> Self {
self.margin = margin;
@@ -114,7 +123,7 @@ impl ColorBar {
}
/// Get the position of the color bar
- pub fn pos(&self) -> ColorBarPos {
+ pub fn pos(&self) -> Pos {
self.pos
}
@@ -138,14 +147,19 @@ impl ColorBar {
self.border.as_ref()
}
+ /// Get the ticks locator
+ pub fn ticks_locator(&self) -> &axis::ticks::Locator {
+ &self.locator
+ }
+
/// Get the margin between the color bar and the plot area
pub fn margin(&self) -> f32 {
self.margin
}
}
-impl From for ColorBar {
- fn from(pos: ColorBarPos) -> Self {
+impl From for ColorBar {
+ fn from(pos: Pos) -> Self {
Self::new(pos)
}
}
diff --git a/src/drawing/cmap.rs b/src/drawing/cmap.rs
index 6856b83..988d900 100644
--- a/src/drawing/cmap.rs
+++ b/src/drawing/cmap.rs
@@ -1,6 +1,7 @@
use std::sync::Arc;
use crate::color::{Lerp, LinRgb, OkLab, Rgb8, Xyz};
+use crate::des;
use crate::des::cmap::{LerpColorMap, LerpMethod};
use crate::drawing::axis;
@@ -14,7 +15,8 @@ pub trait ColorMap {
pub trait AsColorMap {
fn hash(&self) -> u64;
- fn data_range(&self) -> Option;
+ fn forced_data_range(&self) -> Option;
+ fn forced_ticks_locator(&self) -> Option<&des::axis::ticks::Locator>;
/// Convert this type to a `ColorMap` implementation that can be used for color mapping.
fn as_color_map(&self) -> Arc;
@@ -36,18 +38,23 @@ impl AsColorMap for LerpColorMap {
pos_bits.hash(&mut hasher);
stop.1.hash(&mut hasher);
}
- if let Some(range) = self.data_range() {
+ if let Some(range) = self.forced_data_range() {
range.0.to_bits().hash(&mut hasher);
range.1.to_bits().hash(&mut hasher);
}
+ // TODO: hash the locator
hasher.finish()
}
- fn data_range(&self) -> Option {
- self.data_range()
+ fn forced_data_range(&self) -> Option {
+ self.forced_data_range()
.map(|rng| axis::NumBounds::from(rng).into())
}
+ fn forced_ticks_locator(&self) -> Option<&des::axis::ticks::Locator> {
+ self.forced_ticks_locator()
+ }
+
fn as_color_map(&self) -> Arc {
let start = self.start();
let end = self.end();
diff --git a/src/drawing/colorbar.rs b/src/drawing/colorbar.rs
index ee320e3..a8b380e 100644
--- a/src/drawing/colorbar.rs
+++ b/src/drawing/colorbar.rs
@@ -1,7 +1,8 @@
use std::fmt;
use std::sync::Arc;
-use crate::des::{self, ColorBarPos};
+use crate::des::axis::ticks::Locator;
+use crate::des::{self, colorbar};
use crate::drawing::axis::{self, AsBoundRef};
use crate::drawing::cmap::{AsColorMap, ColorMap};
use crate::drawing::{Ctx, Text, ticks};
@@ -27,14 +28,21 @@ pub struct ColorBarBuilder {
hash: u64,
cmap: Arc,
data_bounds: axis::Bounds,
+ locator: Locator,
}
impl ColorBarBuilder {
- pub fn new(hash: u64, cmap: Arc, data_bounds: axis::Bounds) -> Self {
+ pub fn new(
+ hash: u64,
+ cmap: Arc,
+ data_bounds: axis::Bounds,
+ locator: Locator,
+ ) -> Self {
Self {
hash,
cmap,
data_bounds,
+ locator,
}
}
@@ -55,10 +63,10 @@ impl ColorBarBuilder {
D: data::Source + ?Sized,
{
let side = match des.pos() {
- ColorBarPos::Right => axis::Side::Right,
- ColorBarPos::Left => axis::Side::Left,
- ColorBarPos::Top => axis::Side::Top,
- ColorBarPos::Bottom => axis::Side::Bottom,
+ colorbar::Pos::Right => axis::Side::Right,
+ colorbar::Pos::Left => axis::Side::Left,
+ colorbar::Pos::Top => axis::Side::Top,
+ colorbar::Pos::Bottom => axis::Side::Bottom,
};
let title = des
@@ -74,10 +82,10 @@ impl ColorBarBuilder {
let font = des.ticks_font().clone();
let scale: des::axis::Scale =
des::axis::Range::new(Some(nb.start()), Some(nb.end())).into();
- let locator = des::axis::ticks::Locator::Auto;
let formatter = des::axis::ticks::Formatter::Auto;
- let ticks = ticks::locate_num(&locator, *nb, &scale)?;
- let formatter = ticks::num_label_formatter(&locator, Some(&formatter), *nb, &scale);
+ let ticks = ticks::locate_num(&self.locator, *nb, &scale)?;
+ let formatter =
+ ticks::num_label_formatter(&self.locator, Some(&formatter), *nb, &scale);
ticks
.into_iter()
.map(|t| -> Result<_, super::Error> {
@@ -166,7 +174,7 @@ impl ColorDataMap for ColorBar {
}
impl ColorBar {
- pub fn pos(&self) -> ColorBarPos {
+ pub fn pos(&self) -> colorbar::Pos {
self.des.pos()
}
diff --git a/src/drawing/plot.rs b/src/drawing/plot.rs
index 817901d..35f4737 100644
--- a/src/drawing/plot.rs
+++ b/src/drawing/plot.rs
@@ -2,7 +2,7 @@ use std::cell::RefCell;
use std::f32;
use std::rc::Rc;
-use crate::des::{PlotIdx, annot};
+use crate::des::{PlotIdx, annot, colorbar};
use crate::drawing::annot::Annot;
use crate::drawing::axis::{AsBoundRef, Axis, AxisScale, Bounds, Side};
use crate::drawing::colorbar::{ColorBar, ColorBarBuilder};
@@ -515,7 +515,7 @@ where
for_each_series(des_plot, |s| {
if let Some(entry) = s.colorbar_entry() {
- let forced_bounds = entry.cmap.data_range();
+ let forced_bounds = entry.cmap.forced_data_range();
let has_forced_bounds = forced_bounds.is_some();
let bounds = if let Some(range) = forced_bounds {
range
@@ -525,6 +525,10 @@ where
.expect("Should get bounds for colormap data column")
};
+ let locator = entry
+ .cmap
+ .forced_ticks_locator()
+ .unwrap_or(des_colorbar.ticks_locator());
let hash = entry.cmap.hash();
if let Some(cbb) = builders.iter_mut().find(|b| b.hash() == hash) {
@@ -541,6 +545,7 @@ where
hash,
entry.cmap.as_color_map(),
bounds,
+ locator.clone(),
));
}
}
@@ -912,18 +917,18 @@ fn y_side_matches_out_legend_pos(side: des::axis::Side, legend_pos: des::plot::L
}
}
-fn x_side_matches_colorbar_pos(side: des::axis::Side, pos: des::ColorBarPos) -> bool {
+fn x_side_matches_colorbar_pos(side: des::axis::Side, pos: colorbar::Pos) -> bool {
match (side, pos) {
- (des::axis::Side::Main, des::ColorBarPos::Bottom) => true,
- (des::axis::Side::Opposite, des::ColorBarPos::Top) => true,
+ (des::axis::Side::Main, colorbar::Pos::Bottom) => true,
+ (des::axis::Side::Opposite, colorbar::Pos::Top) => true,
_ => false,
}
}
-fn y_side_matches_colorbar_pos(side: des::axis::Side, pos: des::ColorBarPos) -> bool {
+fn y_side_matches_colorbar_pos(side: des::axis::Side, pos: colorbar::Pos) -> bool {
match (side, pos) {
- (des::axis::Side::Main, des::ColorBarPos::Left) => true,
- (des::axis::Side::Opposite, des::ColorBarPos::Right) => true,
+ (des::axis::Side::Main, colorbar::Pos::Left) => true,
+ (des::axis::Side::Opposite, colorbar::Pos::Right) => true,
_ => false,
}
}
diff --git a/tests/refs/colorbar/auto-range.png b/tests/refs/colorbar/auto-range.png
new file mode 100644
index 0000000..04a429c
Binary files /dev/null and b/tests/refs/colorbar/auto-range.png differ
diff --git a/tests/refs/colorbar/auto-range.svg b/tests/refs/colorbar/auto-range.svg
new file mode 100644
index 0000000..8734bf4
--- /dev/null
+++ b/tests/refs/colorbar/auto-range.svg
@@ -0,0 +1,302 @@
+
\ No newline at end of file
diff --git a/tests/refs/colorbar/forced-scale.png b/tests/refs/colorbar/forced-range.png
similarity index 100%
rename from tests/refs/colorbar/forced-scale.png
rename to tests/refs/colorbar/forced-range.png
diff --git a/tests/refs/colorbar/forced-scale.svg b/tests/refs/colorbar/forced-range.svg
similarity index 100%
rename from tests/refs/colorbar/forced-scale.svg
rename to tests/refs/colorbar/forced-range.svg
diff --git a/tests/refs/colorbar/locator.png b/tests/refs/colorbar/locator.png
new file mode 100644
index 0000000..87acfd5
Binary files /dev/null and b/tests/refs/colorbar/locator.png differ
diff --git a/tests/refs/colorbar/locator.svg b/tests/refs/colorbar/locator.svg
new file mode 100644
index 0000000..e7be6fe
--- /dev/null
+++ b/tests/refs/colorbar/locator.svg
@@ -0,0 +1,296 @@
+
\ No newline at end of file
diff --git a/tests/src/tests.rs b/tests/src/tests.rs
index d8ab900..04aa504 100644
--- a/tests/src/tests.rs
+++ b/tests/src/tests.rs
@@ -43,17 +43,33 @@ fn line2(x: &[f64], y: &[f64]) -> des::series::Line {
des::series::Line::new(x.into(), y.into())
}
-/// Get a predictable random number generator
-fn rng(seed: Option) -> impl rand::Rng {
- let seed = seed.unwrap_or(1234567890987654321);
- rand_chacha::ChaCha8Rng::seed_from_u64(seed)
+/// Seed for NotRandom generator
+struct RngSeed(u64);
+
+impl Default for RngSeed {
+ fn default() -> Self {
+ RngSeed(1234567890987654321)
+ }
}
-fn make_col(n: usize, distr: D, rng: &mut impl rand::Rng) -> Vec
-where
- D: rand_distr::Distribution,
-{
- (0..n).map(|_| distr.sample(rng)).collect()
+/// Predictable random number generator
+struct NotRandom {
+ rng: rand_chacha::ChaCha8Rng,
+}
+
+impl NotRandom {
+ fn new(seed: RngSeed) -> Self {
+ NotRandom {
+ rng: rand_chacha::ChaCha8Rng::seed_from_u64(seed.0),
+ }
+ }
+
+ fn make_col(&mut self, n: usize, distr: D) -> Vec
+ where
+ D: rand_distr::Distribution,
+ {
+ (0..n).map(|_| distr.sample(&mut self.rng)).collect()
+ }
}
mod axes;
diff --git a/tests/src/tests/colorbar.rs b/tests/src/tests/colorbar.rs
index 6782e54..9c3dc89 100644
--- a/tests/src/tests/colorbar.rs
+++ b/tests/src/tests/colorbar.rs
@@ -1,33 +1,38 @@
-use plotive::des::cmap;
-use plotive::{des, style};
+use plotive::des::{self, ColorBar, cmap, colorbar};
+use plotive::style;
use rand_distr::Uniform;
use crate::tests::fig_small;
use crate::{TestHarness, assert_fig_eq_ref};
fn columns() -> (Vec, Vec, Vec) {
- let mut rng = super::rng(None);
+ use super::{NotRandom, RngSeed};
+
+ let mut rng = NotRandom::new(RngSeed::default());
let distr = Uniform::new(0.0, 1.0).unwrap();
- let x = super::make_col(15, distr, &mut rng);
- let y = super::make_col(15, distr, &mut rng);
- let col = super::make_col(15, distr, &mut rng);
+ let x = rng.make_col(15, distr);
+ let y = rng.make_col(15, distr);
+ let col = rng.make_col(15, distr);
(x, y, col)
}
+fn scatter(x: Vec, y: Vec) -> des::series::Scatter {
+ des::series::Scatter::new(des::data_inline(x), des::data_inline(y)).with_marker(
+ style::series::Marker::default()
+ .with_fill_opacity(0.7)
+ .with_stroke_width(2.0),
+ )
+}
+
#[test]
fn colorbar_default() {
let (x, y, col) = columns();
let plot = des::Plot::new(vec![
- des::series::Scatter::new(des::data_inline(x), des::data_inline(y))
+ scatter(x, y)
.with_color_data(des::data_inline(col), cmap::viridis())
- .with_marker(
- style::series::Marker::default()
- .with_fill_opacity(0.7)
- .with_stroke_width(2.0),
- )
.into(),
])
.with_colorbar(Default::default());
@@ -36,18 +41,53 @@ fn colorbar_default() {
assert_fig_eq_ref!(&fig, "colorbar/default");
}
+#[test]
+fn colorbar_locator() {
+ let (x, y, col) = columns();
+ let ticks = vec![0.0, 0.25, 0.5, 0.75, 1.0];
+
+ let plot = des::Plot::new(vec![
+ scatter(x, y)
+ .with_color_data(
+ des::data_inline(col),
+ cmap::viridis().force_data_range((0.0, 1.0)),
+ )
+ .into(),
+ ])
+ .with_colorbar(ColorBar::default().with_ticks_locator(ticks.into()));
+ let fig = fig_small(plot);
+
+ assert_fig_eq_ref!(&fig, "colorbar/locator");
+}
+
+#[test]
+fn colorbar_cmap_locator() {
+ let (x, y, col) = columns();
+ let ticks = vec![0.0, 0.25, 0.5, 0.75, 1.0];
+
+ let plot = des::Plot::new(vec![
+ scatter(x, y)
+ .with_color_data(
+ des::data_inline(col),
+ cmap::viridis()
+ .force_data_range((0.0, 1.0))
+ .force_ticks_locator(ticks.into()),
+ )
+ .into(),
+ ])
+ .with_colorbar(ColorBar::default());
+ let fig = fig_small(plot);
+
+ assert_fig_eq_ref!(&fig, "colorbar/locator");
+}
+
#[test]
fn colorbar_default_with_axes() {
let (x, y, col) = columns();
let plot = des::Plot::new(vec![
- des::series::Scatter::new(des::data_inline(x), des::data_inline(y))
+ scatter(x, y)
.with_color_data(des::data_inline(col), cmap::viridis())
- .with_marker(
- style::series::Marker::default()
- .with_fill_opacity(0.7)
- .with_stroke_width(2.0),
- )
.into(),
])
.with_x_axis(
@@ -67,26 +107,39 @@ fn colorbar_default_with_axes() {
}
#[test]
-fn colorbar_forced_scale() {
+fn colorbar_auto_range() {
+ let (x, y, _) = columns();
+ let col = vec![
+ -1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0,
+ ];
+
+ let plot = des::Plot::new(vec![
+ scatter(x, y)
+ .with_color_data(des::data_inline(col), cmap::viridis())
+ .into(),
+ ])
+ .with_colorbar(Default::default());
+ let fig = fig_small(plot);
+
+ assert_fig_eq_ref!(&fig, "colorbar/auto-range");
+}
+
+#[test]
+fn colorbar_forced_range() {
let (x, y, col) = columns();
let plot = des::Plot::new(vec![
- des::series::Scatter::new(des::data_inline(x), des::data_inline(y))
+ scatter(x, y)
.with_color_data(
des::data_inline(col),
- cmap::viridis().with_data_range((0.0, 2.0)),
- )
- .with_marker(
- style::series::Marker::default()
- .with_fill_opacity(0.7)
- .with_stroke_width(2.0),
+ cmap::viridis().force_data_range((0.0, 2.0)),
)
.into(),
])
.with_colorbar(Default::default());
let fig = fig_small(plot);
- assert_fig_eq_ref!(&fig, "colorbar/forced-scale");
+ assert_fig_eq_ref!(&fig, "colorbar/forced-range");
}
#[test]
@@ -94,16 +147,11 @@ fn colorbar_left() {
let (x, y, col) = columns();
let plot = des::Plot::new(vec![
- des::series::Scatter::new(des::data_inline(x), des::data_inline(y))
+ scatter(x, y)
.with_color_data(des::data_inline(col), cmap::viridis())
- .with_marker(
- style::series::Marker::default()
- .with_fill_opacity(0.7)
- .with_stroke_width(2.0),
- )
.into(),
])
- .with_colorbar(des::ColorBarPos::Left.into());
+ .with_colorbar(colorbar::Pos::Left.into());
let fig = fig_small(plot);
assert_fig_eq_ref!(&fig, "colorbar/left");
@@ -114,16 +162,11 @@ fn colorbar_top() {
let (x, y, col) = columns();
let plot = des::Plot::new(vec![
- des::series::Scatter::new(des::data_inline(x), des::data_inline(y))
+ scatter(x, y)
.with_color_data(des::data_inline(col), cmap::viridis())
- .with_marker(
- style::series::Marker::default()
- .with_fill_opacity(0.7)
- .with_stroke_width(2.0),
- )
.into(),
])
- .with_colorbar(des::ColorBarPos::Top.into());
+ .with_colorbar(colorbar::Pos::Top.into());
let fig = fig_small(plot);
assert_fig_eq_ref!(&fig, "colorbar/top");
@@ -134,16 +177,11 @@ fn colorbar_bottom() {
let (x, y, col) = columns();
let plot = des::Plot::new(vec![
- des::series::Scatter::new(des::data_inline(x), des::data_inline(y))
+ scatter(x, y)
.with_color_data(des::data_inline(col), cmap::viridis())
- .with_marker(
- style::series::Marker::default()
- .with_fill_opacity(0.7)
- .with_stroke_width(2.0),
- )
.into(),
])
- .with_colorbar(des::ColorBarPos::Bottom.into());
+ .with_colorbar(colorbar::Pos::Bottom.into());
let fig = fig_small(plot);
assert_fig_eq_ref!(&fig, "colorbar/bottom");