Skip to content

Commit

Permalink
Custom palettes need at least two elements, not at least one.
Browse files Browse the repository at this point in the history
Change the error check + documentation.

Fixes #99
  • Loading branch information
SiegeLordEx authored and SiegeLord committed Mar 23, 2024
1 parent dcbe26d commit b7252ef
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions gnuplot/src/axes_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1395,9 +1395,9 @@ impl AxesCommonData
}
Custom(ref entries) =>
{
if entries.is_empty()
if entries.len() < 2
{
panic!("Need at least 1 element in a custom palette");
panic!("Need at least 2 elements in a custom palette");
}
write!(w, "set palette defined (");

Expand Down
2 changes: 1 addition & 1 deletion gnuplot/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ pub enum PaletteType<T>
/// Use a cube helix palette, with a certain start (in radians), cycles, saturation and gamma.
CubeHelix(f32, f32, f32, f32),
/// A custom palette
/// is specified by a sequence of 4-tuples (with at least one element). The first
/// is specified by a sequence of 4-tuples (with at least two elements). The first
/// element is the grayscale value that is mapped to the remaining three elements
/// which specify the red, green and blue components of the color.
/// The grayscale values must be non-decreasing. All values must range from 0 to 1.
Expand Down

0 comments on commit b7252ef

Please sign in to comment.