Skip to content

Commit b7252ef

Browse files
SiegeLordExSiegeLord
authored andcommitted
Custom palettes need at least two elements, not at least one.
Change the error check + documentation. Fixes #99
1 parent dcbe26d commit b7252ef

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

gnuplot/src/axes_common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,9 +1395,9 @@ impl AxesCommonData
13951395
}
13961396
Custom(ref entries) =>
13971397
{
1398-
if entries.is_empty()
1398+
if entries.len() < 2
13991399
{
1400-
panic!("Need at least 1 element in a custom palette");
1400+
panic!("Need at least 2 elements in a custom palette");
14011401
}
14021402
write!(w, "set palette defined (");
14031403

gnuplot/src/options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ pub enum PaletteType<T>
421421
/// Use a cube helix palette, with a certain start (in radians), cycles, saturation and gamma.
422422
CubeHelix(f32, f32, f32, f32),
423423
/// A custom palette
424-
/// is specified by a sequence of 4-tuples (with at least one element). The first
424+
/// is specified by a sequence of 4-tuples (with at least two elements). The first
425425
/// element is the grayscale value that is mapped to the remaining three elements
426426
/// which specify the red, green and blue components of the color.
427427
/// The grayscale values must be non-decreasing. All values must range from 0 to 1.

0 commit comments

Comments
 (0)