Skip to content

Simplify box width API #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gnuplot/examples/box_and_whisker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ fn example(c: Common)

fg.axes2d()
.set_title("Box and whisker", &[])
.box_and_whisker_set_width(
.box_and_whisker(
[-0.6f32, 1.5, 2.5].iter(),
[-1.0f32, 0.0, 1.0].iter(),
[-2.0f32, -1.0, 0.0].iter(),
[2.0f32, 3.0, 4.0].iter(),
[1.0f32, 2.0, 3.0].iter(),
[0.5f32, 0.25, 0.125].iter(),
&[
BoxWidth([0.5f64, 0.25, 0.125].into()),
WhiskerBars(0.5),
Color("blue".into()),
LineWidth(2.0),
Expand Down
6 changes: 2 additions & 4 deletions gnuplot/examples/example2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use crate::common::*;

use gnuplot::*;
use std::iter::repeat;

mod common;

Expand All @@ -17,7 +16,6 @@ fn example(c: Common)
let x2 = x2.iter2();
let y2: Vec<i32> = x2.map(|&v| v * v).collect();
let y2 = y2.iter2();
let w = repeat(0.5f32);

let x3 = &[1i32, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
let x3 = x3.iter2();
Expand Down Expand Up @@ -83,14 +81,14 @@ fn example(c: Common)
LineStyle(DotDash),
],
)
.boxes_set_width(
.boxes(
x,
y1,
w,
&[
LineWidth(2.0),
Color("gray".into()),
BorderColor("black".into()),
BoxWidth([0.5, 0.4, 0.55, 0.7, 0.2].into()),
],
);

Expand Down
1 change: 1 addition & 0 deletions gnuplot/examples/inverse_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ impl PlotElement for Lines
WhiskerBars(v) => WhiskerBars(*v),
FillPattern(v) => FillPattern(*v),
Axes(v1, v2) => Axes(*v1, *v2),
BoxWidth(v) => BoxWidth(v.to_vec()),
});
}

Expand Down
6 changes: 3 additions & 3 deletions gnuplot/examples/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ fn example(c: Common)
ax.set_title("Patterns", &[]);
ax.set_legend(Graph(1.), Graph(0.95), &[MaxRows(3)], &[]);
ax.set_y_range(Auto, Fix(8.));
ax.set_box_width(0.5, false);
for i in 0..=8
{
ax.boxes_set_width(&[i], &[5], &[0.5], &[FillPattern(Auto)]);
ax.boxes(&[i], &[5], &[FillPattern(Auto)]);
}

for (i, &pattern) in [
Expand All @@ -31,10 +32,9 @@ fn example(c: Common)
.iter()
.enumerate()
{
ax.boxes_set_width(
ax.boxes(
&[i],
&[-5],
&[0.5],
&[
FillPattern(Fix(pattern)),
Caption(&format!("{:?}", pattern)),
Expand Down
46 changes: 23 additions & 23 deletions gnuplot/examples/variable_color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,34 +87,34 @@ fn example(c: Common)
ax.set_title(
&format!("variable color boxerror, points, xyerrorbars, and boxxyerror.\nColor used is a {label}"),
&[],
);
ax.set_y_range(Fix(-4.0), Fix(11.5));
ax.box_error_low_high_set_width(
)
.set_y_range(Fix(-4.0), Fix(11.5))
.set_box_width(0.5, true)
.box_error_low_high(
&d1,
&d5,
&d2,
&d6,
iter::repeat(0.2),
&[
color.clone(),
FillAlpha(0.5),
BorderColor(RGBString("black")),
],
);
ax.points(&d1, iter::repeat(1), &[color.clone(), PointSymbol('D')]);
ax.xy_error_bars(
)
.points(&d1, iter::repeat(1), &[color.clone(), PointSymbol('D')])
.xy_error_bars(
&d1,
iter::repeat(8),
d1.iter().map(by3),
d1.iter().map(by4),
&[color.clone()],
);
ax.points(
)
.points(
&d1,
d2.iter().map(|v| -v / 2.0),
&[color.clone(), PointSymbol('O'), PointSize(3.0)],
);
ax.box_xy_error_delta(
)
.box_xy_error_delta(
&d1,
iter::repeat(10),
d1.iter().map(by3),
Expand Down Expand Up @@ -153,21 +153,21 @@ fn example(c: Common)
ax.set_title(
&format!("variable color boxerror, points, xyerrorbars, and boxxyerror.\nColor used is a SavedColormap"),
&[],
);
ax.set_y_range(Fix(-4.0), Fix(11.5));
ax.box_error_low_high_set_width(
)
.set_y_range(Fix(-4.0), Fix(11.5))
.set_box_width(0.8, false)
.box_error_low_high(
&d1,
&d5,
&d2,
&d6,
iter::repeat(0.2),
&[
Color(SavedColorMap("magma", color_values.clone())),
FillAlpha(0.5),
BorderColor(RGBString("black")),
],
);
ax.points(
)
.points(
&d1,
iter::repeat(1),
&[
Expand All @@ -177,24 +177,24 @@ fn example(c: Common)
)),
PointSymbol('D'),
],
);
ax.xy_error_bars(
)
.xy_error_bars(
&d1,
iter::repeat(8),
d1.iter().map(by3),
d1.iter().map(by4),
&[Color(SavedColorMap("ocean", color_values.clone()))],
);
ax.points(
)
.points(
&d1,
d2.iter().map(|v| -v / 2.0),
&[
Color(SavedColorMap("magma", color_values.clone())),
PointSymbol('O'),
PointSize(3.0),
],
);
ax.box_xy_error_delta(
)
.box_xy_error_delta(
&d1,
iter::repeat(10),
d1.iter().map(by3),
Expand Down
Loading