Skip to content

Commit 76029b4

Browse files
committed
FIx sample code in docs
1 parent 359b403 commit 76029b4

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

gnuplot/src/color.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,20 @@ pub enum ColorType<T = String>
7878
///
7979
/// Comparing with [PaletteCBColor]: given the following code
8080
/// ```
81-
/// assert!(frac <= 0.0)
82-
/// assert!(frac >= 1.0)
83-
/// ax.set_cb_range(Fix(min), Fix(max))
84-
/// let col1 = PalleteFracColor(frac)
81+
/// use gnuplot::{PaletteCBColor, PaletteFracColor, Fix, Figure, AxesCommon, Color};
82+
/// let min = -5.0; // or any value
83+
/// let max = 12.0; // or any value
84+
///
85+
/// let frac = 0.5; // or any value 0.0 <= frac <= 1.0
86+
/// assert!(frac >= 0.0);
87+
/// assert!(frac <= 1.0);
88+
///
89+
/// let mut fg = Figure::new();
90+
/// let ax = fg.axes2d();
91+
/// ax.set_cb_range(Fix(min), Fix(max));
92+
/// let col1 = Color(PaletteFracColor(frac));
8593
/// let cb_range = max - min;
86-
/// let col2 = PaletteCBColor(min + (frac * cb_range))
94+
/// let col2 = Color(PaletteCBColor(min + (frac * cb_range)));
8795
/// ```
8896
/// `col1` and `col2` should give the same color.
8997
PaletteCBColor(f64),

0 commit comments

Comments
 (0)