Skip to content

Commit c32dbe0

Browse files
committed
Merge branch 'Ploppz-plot'
2 parents b928842 + 2eb09fa commit c32dbe0

20 files changed

Lines changed: 300 additions & 359 deletions

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- Group all representations under a `repr` module.
1010
- Add `linejoin` option to line style.
1111
- More Box and less & in the interface
12+
- Replace Line, Scatter and Function with Plot
1213

1314
## 0.4.0 - 2019-03-02
1415
### Added

examples/barchart_svg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn main() {
77
let b1 = BarChart::new(5.3).label("1");
88
let b2 = BarChart::new(2.6)
99
.label("2")
10-
.style(BoxStyle::new().fill("darkolivegreen"));
10+
.style(&BoxStyle::new().fill("darkolivegreen"));
1111

1212
let v = CategoricalView::new()
1313
.add(b1)

examples/boxplot_svg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn main() {
77
let b1 = BoxPlot::from_slice(&[1.0, 4.0, 2.0, 3.5, 6.4, 2.5, 7.5, 1.8, 9.6]).label("1");
88
let b2 = BoxPlot::from_slice(&[3.0, 4.3, 2.0, 3.5, 6.9, 4.5, 7.5, 1.8, 10.6])
99
.label("2")
10-
.style(BoxStyle::new().fill("darkolivegreen"));
10+
.style(&BoxStyle::new().fill("darkolivegreen"));
1111

1212
let v = CategoricalView::new()
1313
.add(b1)

examples/function_svg.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
use plotlib::repr::Function;
21
use plotlib::page::Page;
2+
use plotlib::repr::Plot;
33
use plotlib::style::LineStyle;
44
use plotlib::view::ContinuousView;
55

66
fn main() {
7-
let f1 = Function::new(|x| x * 5., 0., 10.).style(LineStyle::new().colour("burlywood"));
8-
let f2 = Function::new(|x| x.powi(2), 0., 10.)
9-
.style(LineStyle::new().colour("darkolivegreen").width(2.));
10-
let f3 = Function::new(|x| x.sqrt() * 20., 0., 10.)
11-
.style(LineStyle::new().colour("brown").width(1.));
7+
let f1 = Plot::from_function(|x| x * 5., 0., 10.).line_style(LineStyle::new().colour("burlywood"));
8+
let f2 = Plot::from_function(|x| x.powi(2), 0., 10.)
9+
.line_style(LineStyle::new().colour("darkolivegreen").width(2.));
10+
let f3 = Plot::from_function(|x| x.sqrt() * 20., 0., 10.)
11+
.line_style(LineStyle::new().colour("brown").width(1.));
1212

1313
let v = ContinuousView::new().add(f1).add(f2).add(f3);
1414

examples/histogram_svg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use plotlib::view::ContinuousView;
66
fn main() {
77
let data = [0.3, 0.5, 6.4, 5.3, 3.6, 3.6, 3.5, 7.5, 4.0];
88
let h = Histogram::from_slice(&data, HistogramBins::Count(10))
9-
.style(BoxStyle::new().fill("burlywood"));
9+
.style(&BoxStyle::new().fill("burlywood"));
1010

1111
let v = ContinuousView::new().add(h);
1212

examples/line_and_point_svg.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use plotlib::page::Page;
2+
use plotlib::repr::Plot;
3+
use plotlib::style::*;
4+
use plotlib::view::ContinuousView;
5+
6+
fn main() {
7+
let l1 = Plot::new(vec![(0., 1.), (2., 1.5), (3., 1.2), (4., 1.1)])
8+
.line_style(LineStyle::new().colour("burlywood").linejoin(LineJoin::Round))
9+
.point_style(PointStyle::new());
10+
11+
let v = ContinuousView::new().add(l1);
12+
Page::single(&v).save("line_and_point.svg").expect("saving svg");
13+
}

examples/line_svg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use plotlib::page::Page;
2-
use plotlib::repr::Line;
2+
use plotlib::repr::Plot;
33
use plotlib::style::{LineJoin, LineStyle};
44
use plotlib::view::ContinuousView;
55

66
fn main() {
7-
let l1 = Line::new(vec![(0., 1.), (2., 1.5), (3., 1.2), (4., 1.1)]).style(
7+
let l1 = Plot::new(vec![(0., 1.), (2., 1.5), (3., 1.2), (4., 1.1)]).line_style(
88
LineStyle::new()
99
.colour("burlywood")
1010
.linejoin(LineJoin::Round),

examples/scatter_svg.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
use plotlib::page::Page;
2-
use plotlib::repr::Scatter;
2+
use plotlib::repr::Plot;
33
use plotlib::style::{PointMarker, PointStyle};
44
use plotlib::view::ContinuousView;
55

66
fn main() {
7-
let data = [
7+
let data = vec![
88
(-3.0, 2.3),
99
(-1.6, 5.3),
1010
(0.3, 0.7),
1111
(4.3, -1.4),
1212
(6.4, 4.3),
1313
(8.5, 3.7),
1414
];
15-
let s1 = Scatter::from_slice(&data).style(
15+
let s1 = Plot::new(data).point_style(
1616
PointStyle::new()
1717
.marker(PointMarker::Square)
1818
.colour("burlywood")
1919
.size(2.),
2020
);
21-
let s2 = Scatter::from_slice(&[(-1.4, 2.5), (7.2, -0.3)])
22-
.style(PointStyle::new().colour("darkseagreen"));
21+
let s2 = Plot::new(vec![(-1.4, 2.5), (7.2, -0.3)])
22+
.point_style(PointStyle::new().colour("darkseagreen"));
2323

2424
let v = ContinuousView::new()
2525
.add(s1)

examples/scatter_text.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
use plotlib::page::Page;
2-
use plotlib::repr::Scatter;
2+
use plotlib::repr::Plot;
33
use plotlib::style::{PointMarker, PointStyle};
44
use plotlib::view::ContinuousView;
55

66
fn main() {
7-
let data = [
7+
let data = vec![
88
(-3.0, 2.3),
99
(-1.6, 5.3),
1010
(0.3, 0.7),
1111
(4.3, -1.4),
1212
(6.4, 4.3),
1313
(8.5, 3.7),
1414
];
15-
let s1 = Scatter::from_slice(&data);
16-
let s2 = Scatter::from_slice(&[(-1.4, 2.5), (7.2, -0.3)])
17-
.style(PointStyle::new().marker(PointMarker::Square));
15+
let s1 = Plot::new(data);
16+
let s2 = Plot::new(vec![(-1.4, 2.5), (7.2, -0.3)])
17+
.point_style(PointStyle::new().marker(PointMarker::Square));
1818

1919
let v = ContinuousView::new()
2020
.add(s1)

examples/with_grid.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use plotlib::repr::{BarChart, Line};
1+
use plotlib::repr::{BarChart, Plot};
22
use plotlib::grid::Grid;
33
use plotlib::page::Page;
44
use plotlib::style::{BoxStyle, LineStyle};
@@ -13,8 +13,8 @@ fn render_line_chart<S>(filename: S)
1313
where
1414
S: AsRef<str>,
1515
{
16-
let l1 = Line::new(vec![(0., 1.), (2., 1.5), (3., 1.2), (4., 1.1)])
17-
.style(LineStyle::new().colour("burlywood"));
16+
let l1 = Plot::new(vec![(0., 1.), (2., 1.5), (3., 1.2), (4., 1.1)])
17+
.line_style(LineStyle::new().colour("burlywood"));
1818
let mut v = ContinuousView::new().add(l1);
1919
v.add_grid(Grid::new(3, 8));
2020
Page::single(&v)
@@ -29,7 +29,7 @@ where
2929
let b1 = BarChart::new(5.3).label("1");
3030
let b2 = BarChart::new(2.6)
3131
.label("2")
32-
.style(BoxStyle::new().fill("darkolivegreen"));
32+
.style(&BoxStyle::new().fill("darkolivegreen"));
3333
let mut v = CategoricalView::new()
3434
.add(b1)
3535
.add(b2)

0 commit comments

Comments
 (0)