Skip to content

Commit 5fcea76

Browse files
authored
Merge branch 'main' into multiples-axis
2 parents 3e910b2 + 7bfae55 commit 5fcea76

File tree

31 files changed

+99
-90
lines changed

31 files changed

+99
-90
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
55

6+
## [0.9.1] - 2024-09-06
7+
### Added
8+
- [[#217](https://github.com/plotly/plotly.rs/pull/217)] Added show_html(filename) method to bypass situations where accessing default `/tmp` is not possible, e.g., with in SNAP Firefox
9+
- [[#227](https://github.com/plotly/plotly.rs/pull/227)] Switch from HTML template render from `askama` to `rinja`
10+
11+
### Fixed
12+
- [[#232](https://github.com/plotly/plotly.rs/pull/232)] Generalize OS detection in the context of opening HTML pages with default app via `xdg-open`
13+
- [[#233](https://github.com/plotly/plotly.rs/pull/233)] Fix mdBook code examples
14+
615
## [0.9.0] - 2024-06-29
716
### Added
817
- [[#153](https://github.com/plotly/plotly.rs/pull/153)] Added `LayoutScene`.

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Add this to your `Cargo.toml`:
6161

6262
```toml
6363
[dependencies]
64-
plotly = "0.9.0"
64+
plotly = "0.9.1"
6565
```
6666

6767
## Exporting an Interactive Plot
@@ -103,7 +103,7 @@ To save a plot as a static image, the `kaleido` feature is required:
103103
# Cargo.toml
104104

105105
[dependencies]
106-
plotly = { version = "0.9.0", features = ["kaleido"] }
106+
plotly = { version = "0.9.1", features = ["kaleido"] }
107107
```
108108

109109
With this feature enabled, plots can be saved as any of `png`, `jpeg`, `webp`, `svg`, `pdf` and `eps`. Note that the plot will be a static image, i.e. they will be non-interactive.
@@ -130,7 +130,7 @@ Using `Plotly.rs` in a Wasm-based frontend framework is possible by enabling the
130130
# Cargo.toml
131131

132132
[dependencies]
133-
plotly = { version = "0.9.0", features = ["wasm"] }
133+
plotly = { version = "0.9.1", features = ["wasm"] }
134134
```
135135

136136
First, make sure that you have the Plotly JavaScript library in your base HTML template:

docs/book/src/fundamentals/shapes.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use plotly::layout::{
1111
Axis, GridPattern, Layout, LayoutGrid, Margin, Shape, ShapeLayer, ShapeLine,
1212
ShapeType,
1313
};
14-
use plotly::{Bar, NamedColor, Plot, Scatter};
14+
use plotly::{Bar, color::NamedColor, Plot, Scatter};
1515
use rand::thread_rng;
1616
use rand_distr::{Distribution, Normal};
1717
```

docs/book/src/getting_started.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ To start using [plotly.rs](https://github.com/plotly/plotly.rs) in your project
2222

2323
```toml
2424
[dependencies]
25-
plotly = "0.9.0"
25+
plotly = "0.9.1"
2626
```
2727

2828
[Plotly.rs](https://github.com/plotly/plotly.rs) is ultimately a thin wrapper around the `plotly.js` library. The main job of this library is to provide `structs` and `enums` which get serialized to `json` and passed to the `plotly.js` library to actually do the heavy lifting. As such, if you are familiar with `plotly.js` or its derivatives (e.g. the equivalent Python library), then you should find [`plotly.rs`](https://github.com/plotly/plotly.rs) intuitive to use.
@@ -97,7 +97,7 @@ To add the ability to save plots in the following formats: png, jpeg, webp, svg,
9797

9898
```toml
9999
[dependencies]
100-
plotly = { version = "0.9.0", features = ["kaleido"] }
100+
plotly = { version = "0.9.1", features = ["kaleido"] }
101101
```
102102

103103
## WebAssembly Support

docs/book/src/recipes/basic_charts/bar_charts.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ use plotly::common::{
88
ColorScale, ColorScalePalette, DashType, Fill, Font, Line, LineShape, Marker, Mode, Title,
99
};
1010
use plotly::layout::{Axis, BarMode, Layout, Legend, TicksDirection};
11-
use plotly::{Bar, NamedColor, Plot, Rgb, Rgba, Scatter};
11+
use plotly::{Bar, color::{NamedColor, Rgb, Rgba}, Plot, Scatter};
1212
use rand_distr::{Distribution, Normal, Uniform};
1313
```
1414

1515
The `to_inline_html` method is used to produce the html plot displayed in this page.
1616

1717

1818
## Basic Bar Chart
19-
```rust
19+
```rust
2020
fn basic_bar_chart(show: bool) {
2121
let animals = vec!["giraffes", "orangutans", "monkeys"];
2222
let t = Bar::new(animals, vec![20, 14, 23]);
@@ -43,7 +43,7 @@ var layout = {};
4343
</script>
4444

4545
## Grouped Bar Chart
46-
```rust
46+
```rust
4747
fn grouped_bar_chart(show: bool) {
4848
let animals1 = vec!["giraffes", "orangutans", "monkeys"];
4949
let trace1 = Bar::new(animals1, vec![20, 14, 23]).name("SF Zoo");
@@ -79,7 +79,7 @@ var layout = {"barmode":"group"};
7979

8080

8181
## Stacked Bar Chart
82-
```rust
82+
```rust
8383
fn stacked_bar_chart(show: bool) {
8484
let animals1 = vec!["giraffes", "orangutans", "monkeys"];
8585
let trace1 = Bar::new(animals1, vec![20, 14, 23]).name("SF Zoo");

docs/book/src/recipes/basic_charts/line_charts.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use plotly::common::{
88
ColorScale, ColorScalePalette, DashType, Fill, Font, Line, LineShape, Marker, Mode, Title,
99
};
1010
use plotly::layout::{Axis, BarMode, Layout, Legend, TicksDirection};
11-
use plotly::{Bar, NamedColor, Plot, Rgb, Rgba, Scatter};
11+
use plotly::{Bar, color::{NamedColor, Rgb, Rgba}, Plot, Scatter};
1212
use rand_distr::{Distribution, Normal, Uniform};
1313
```
1414

@@ -28,7 +28,7 @@ fn adding_names_to_line_and_scatter_plot(show: bool) {
2828
.mode(Mode::LinesMarkers)
2929
.name("Scatter + Lines");
3030

31-
let layout = Layout::new().title(Title::new("Adding Names to Line and Scatter Plot"));
31+
let layout = Layout::new().title(Title::with_text("Adding Names to Line and Scatter Plot"));
3232
let mut plot = Plot::new();
3333
plot.add_trace(trace1);
3434
plot.add_trace(trace2);
@@ -74,7 +74,7 @@ fn line_and_scatter_styling(show: bool) {
7474
.marker(Marker::new().color(Rgb::new(128, 0, 128)).size(12))
7575
.line(Line::new().color(Rgb::new(128, 0, 128)).width(1.0));
7676

77-
let layout = Layout::new().title(Title::new("Line and Scatter Styling"));
77+
let layout = Layout::new().title(Title::with_text("Line and Scatter Styling"));
7878
let mut plot = Plot::new();
7979
plot.add_trace(trace1);
8080
plot.add_trace(trace2);
@@ -114,7 +114,7 @@ fn styling_line_plot(show: bool) {
114114
.line(Line::new().color(Rgb::new(55, 128, 191)).width(1.0));
115115

116116
let layout = Layout::new()
117-
.title(Title::new("Styling Line Plot"))
117+
.title(Title::with_text("Styling Line Plot"))
118118
.width(500)
119119
.height(500);
120120
let mut plot = Plot::new();

docs/book/src/recipes/basic_charts/scatter_plots.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use plotly::common::{
88
ColorScale, ColorScalePalette, DashType, Fill, Font, Line, LineShape, Marker, Mode, Title,
99
};
1010
use plotly::layout::{Axis, BarMode, Layout, Legend, TicksDirection};
11-
use plotly::{Bar, NamedColor, Plot, Rgb, Rgba, Scatter};
11+
use plotly::{Bar, color::{NamedColor, Rgb, Rgba}, Plot, Scatter};
1212
use rand_distr::{Distribution, Normal, Uniform};
1313
```
1414

@@ -156,9 +156,9 @@ fn data_labels_hover(show: bool) {
156156
plot.add_trace(trace2);
157157

158158
let layout = Layout::new()
159-
.title(Title::new("Data Labels Hover"))
160-
.x_axis(Axis::new().title(Title::new("x")).range(vec![0.75, 5.25]))
161-
.y_axis(Axis::new().title(Title::new("y")).range(vec![0., 8.]));
159+
.title(Title::with_text("Data Labels Hover"))
160+
.x_axis(Axis::new().title(Title::with_text("x")).range(vec![0.75, 5.25]))
161+
.y_axis(Axis::new().title(Title::with_text("y")).range(vec![0., 8.]));
162162
plot.set_layout(layout);
163163
if show {
164164
plot.show();
@@ -201,7 +201,7 @@ fn data_labels_on_the_plot(show: bool) {
201201
plot.add_trace(trace2);
202202

203203
let layout = Layout::new()
204-
.title(Title::new("Data Labels on the Plot"))
204+
.title(Title::with_text("Data Labels on the Plot"))
205205
.x_axis(Axis::new().range(vec![0.75, 5.25]))
206206
.y_axis(Axis::new().range(vec![0., 8.]));
207207
plot.set_layout(layout);
@@ -295,14 +295,14 @@ fn colored_and_styled_scatter_plot(show: bool) {
295295
.marker(Marker::new().color(Rgb::new(142, 124, 195)).size(12));
296296

297297
let layout = Layout::new()
298-
.title(Title::new("Quarter 1 Growth"))
298+
.title(Title::with_text("Quarter 1 Growth"))
299299
.x_axis(
300300
Axis::new()
301-
.title(Title::new("GDP per Capita"))
301+
.title(Title::with_text("GDP per Capita"))
302302
.show_grid(false)
303303
.zero_line(false),
304304
)
305-
.y_axis(Axis::new().title(Title::new("Percent")).show_line(false));
305+
.y_axis(Axis::new().title(Title::with_text("Percent")).show_line(false));
306306
let mut plot = Plot::new();
307307
plot.add_trace(trace1);
308308
plot.add_trace(trace2);

docs/book/src/recipes/financial_charts/time_series_and_date_axes.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn time_series_plot_with_custom_date_range(show: bool) {
2727

2828
let layout = Layout::new()
2929
.x_axis(Axis::new().range(vec!["2016-07-01", "2016-12-31"]))
30-
.title(Title::new("Manually Set Date Range"));
30+
.title(Title::with_text("Manually Set Date Range"));
3131
plot.set_layout(layout);
3232

3333
if show {
@@ -68,7 +68,7 @@ fn time_series_with_range_slider(show: bool) {
6868

6969
let layout = Layout::new()
7070
.x_axis(Axis::new().range_slider(RangeSlider::new().visible(true)))
71-
.title(Title::new("Manually Set Date Range"));
71+
.title(Title::with_text("Manually Set Date Range"));
7272
plot.set_layout(layout);
7373

7474
if show {

docs/book/src/recipes/scientific_charts/contour_plots.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ fn colorscale_for_contour_plot(show: bool) {
7272
];
7373
let trace = Contour::new_z(z).color_scale(ColorScale::Palette(ColorScalePalette::Jet));
7474

75-
let layout = Layout::new().title(Title::new("Colorscale for Contour Plot"));
75+
let layout = Layout::new().title(Title::with_text("Colorscale for Contour Plot"));
7676
let mut plot = Plot::new();
7777
plot.set_layout(layout);
7878
plot.add_trace(trace);
@@ -115,7 +115,7 @@ fn customizing_size_and_range_of_a_contour_plots_contours(show: bool) {
115115
.auto_contour(false)
116116
.contours(Contours::new().start(0.0).end(8.0).size(2));
117117

118-
let layout = Layout::new().title(Title::new("Customizing Size and Range of Contours"));
118+
let layout = Layout::new().title(Title::with_text("Customizing Size and Range of Contours"));
119119
let mut plot = Plot::new();
120120
plot.set_layout(layout);
121121
plot.add_trace(trace);
@@ -161,7 +161,7 @@ fn customizing_spacing_between_x_and_y_ticks(show: bool) {
161161
.dy(10.0)
162162
.y0(10.0);
163163

164-
let layout = Layout::new().title(Title::new("Customizing Size and Range of Contours"));
164+
let layout = Layout::new().title(Title::with_text("Customizing Size and Range of Contours"));
165165
let mut plot = Plot::new();
166166
plot.set_layout(layout);
167167
plot.add_trace(trace);

docs/book/src/recipes/statistical_charts/box_plots.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use plotly::box_plot::{BoxMean, BoxPoints};
88
use plotly::common::{ErrorData, ErrorType, Line, Marker, Mode, Orientation, Title};
99
use plotly::histogram::{Bins, Cumulative, HistFunc, HistNorm};
1010
use plotly::layout::{Axis, BarMode, BoxMode, Layout, Margin};
11-
use plotly::{Bar, BoxPlot, Histogram, NamedColor, Plot, Rgb, Rgba, Scatter};
11+
use plotly::{Bar, BoxPlot, Histogram, color::{NamedColor, Rgb, Rgba}, Scatter};
1212
use rand_distr::{Distribution, Normal, Uniform};
1313

1414
```
@@ -156,7 +156,7 @@ fn grouped_box_plot(show: bool) {
156156
let layout = Layout::new()
157157
.y_axis(
158158
Axis::new()
159-
.title(Title::new("normalized moisture"))
159+
.title(Title::with_text("normalized moisture"))
160160
.zero_line(false),
161161
)
162162
.box_mode(BoxMode::Group);
@@ -222,7 +222,7 @@ fn box_plot_styling_outliers(show: bool) {
222222
.marker(Marker::new().color(Rgb::new(107, 174, 214)))
223223
.box_points(BoxPoints::Outliers);
224224

225-
let layout = Layout::new().title(Title::new("Box Plot Styling Outliers"));
225+
let layout = Layout::new().title(Title::with_text("Box Plot Styling Outliers"));
226226

227227
let mut plot = Plot::new();
228228
plot.set_layout(layout);
@@ -272,7 +272,7 @@ fn box_plot_styling_mean_and_standard_deviation(show: bool) {
272272
.name("Mean and Standard Deviation")
273273
.marker(Marker::new().color(Rgb::new(8, 81, 156)))
274274
.box_mean(BoxMean::StandardDeviation);
275-
let layout = Layout::new().title(Title::new("Box Plot Styling Mean and Standard Deviation"));
275+
let layout = Layout::new().title(Title::with_text("Box Plot Styling Mean and Standard Deviation"));
276276

277277
let mut plot = Plot::new();
278278
plot.set_layout(layout);
@@ -341,10 +341,10 @@ fn grouped_horizontal_box_plot(show: bool) {
341341
plot.add_trace(trace3);
342342

343343
let layout = Layout::new()
344-
.title(Title::new("Grouped Horizontal Box Plot"))
344+
.title(Title::with_text("Grouped Horizontal Box Plot"))
345345
.x_axis(
346346
Axis::new()
347-
.title(Title::new("normalized moisture"))
347+
.title(Title::with_text("normalized moisture"))
348348
.zero_line(false),
349349
)
350350
.box_mode(BoxMode::Group);

docs/book/src/recipes/statistical_charts/error_bars.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use plotly::box_plot::{BoxMean, BoxPoints};
88
use plotly::common::{ErrorData, ErrorType, Line, Marker, Mode, Orientation, Title};
99
use plotly::histogram::{Bins, Cumulative, HistFunc, HistNorm};
1010
use plotly::layout::{Axis, BarMode, BoxMode, Layout, Margin};
11-
use plotly::{Bar, BoxPlot, Histogram, NamedColor, Plot, Rgb, Rgba, Scatter};
11+
use plotly::{Bar, BoxPlot, Histogram, Plot, color::{NamedColor, Rgb, Rgba}, Scatter};
1212
use rand_distr::{Distribution, Normal, Uniform};
1313

1414
```

docs/book/src/recipes/statistical_charts/histograms.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use plotly::box_plot::{BoxMean, BoxPoints};
88
use plotly::common::{ErrorData, ErrorType, Line, Marker, Mode, Orientation, Title};
99
use plotly::histogram::{Bins, Cumulative, HistFunc, HistNorm};
1010
use plotly::layout::{Axis, BarMode, BoxMode, Layout, Margin};
11-
use plotly::{Bar, BoxPlot, Histogram, NamedColor, Plot, Rgb, Rgba, Scatter};
11+
use plotly::{Bar, BoxPlot, Histogram, Plot, color::{NamedColor, Rgb, Rgba}, Scatter};
1212
use rand_distr::{Distribution, Normal, Uniform};
1313

1414
```
@@ -201,9 +201,9 @@ fn colored_and_styled_histograms(show: bool) {
201201
.auto_bin_x(false)
202202
.x_bins(Bins::new(-3.2, 4.0, 0.06));
203203
let layout = Layout::new()
204-
.title(Title::new("Sampled Results"))
205-
.x_axis(Axis::new().title(Title::new("Value")))
206-
.y_axis(Axis::new().title(Title::new("Count")))
204+
.title(Title::with_text("Sampled Results"))
205+
.x_axis(Axis::new().title(Title::with_text("Value")))
206+
.y_axis(Axis::new().title(Title::with_text("Count")))
207207
.bar_mode(BarMode::Overlay)
208208
.bar_gap(0.05)
209209
.bar_group_gap(0.2);

docs/book/src/recipes/subplots/multiple_axes.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
The following imports have been used to produce the plots below:
44

55
```rust
6-
use plotly::common::{Font, Side, Title};
6+
use plotly::common::{Font, AxisSide, Title};
77
use plotly::layout::{Axis, GridPattern, Layout, LayoutGrid, Legend, RowOrder};
88
use plotly::{Plot, Rgb, Scatter};
99
```
@@ -23,14 +23,14 @@ fn two_y_axes(show: bool) {
2323
plot.add_trace(trace2);
2424

2525
let layout = Layout::new()
26-
.title(Title::new("Double Y Axis Example"))
27-
.y_axis(Axis::new().title(Title::new("yaxis title")))
26+
.title(Title::with_text("Double Y Axis Example"))
27+
.y_axis(Axis::new().title(Title::with_text("yaxis title")))
2828
.y_axis2(
2929
Axis::new()
30-
.title(Title::new("yaxis2 title").font(Font::new().color(Rgb::new(148, 103, 189))))
30+
.title(Title::with_text("yaxis2 title").font(Font::new().color(Rgb::new(148, 103, 189))))
3131
.tick_font(Font::new().color(Rgb::new(148, 103, 189)))
3232
.overlaying("y")
33-
.side(Side::Right),
33+
.side(AxisSide::Right),
3434
);
3535
plot.set_layout(layout);
3636
if show {
@@ -71,38 +71,38 @@ fn multiple_axes(show: bool) {
7171
plot.add_trace(trace4);
7272

7373
let layout = Layout::new()
74-
.title(Title::new("multiple y-axes example"))
74+
.title(Title::with_text("multiple y-axes example"))
7575
.width(800)
7676
.x_axis(Axis::new().domain(&[0.3, 0.7]))
7777
.y_axis(
7878
Axis::new()
79-
.title(Title::new("yaxis title").font(Font::new().color("#1f77b4")))
79+
.title(Title::with_text("yaxis title").font(Font::new().color("#1f77b4")))
8080
.tick_font(Font::new().color("#1f77b4")),
8181
)
8282
.y_axis2(
8383
Axis::new()
84-
.title(Title::new("yaxis2 title").font(Font::new().color("#ff7f0e")))
84+
.title(Title::with_text("yaxis2 title").font(Font::new().color("#ff7f0e")))
8585
.tick_font(Font::new().color("#ff7f0e"))
8686
.anchor("free")
8787
.overlaying("y")
88-
.side(Side::Left)
88+
.side(AxisSide::Left)
8989
.position(0.15),
9090
)
9191
.y_axis3(
9292
Axis::new()
93-
.title(Title::new("yaxis3 title").font(Font::new().color("#d62728")))
93+
.title(Title::with_text("yaxis3 title").font(Font::new().color("#d62728")))
9494
.tick_font(Font::new().color("#d62728"))
9595
.anchor("x")
9696
.overlaying("y")
97-
.side(Side::Right),
97+
.side(AxisSide::Right),
9898
)
9999
.y_axis4(
100100
Axis::new()
101-
.title(Title::new("yaxis4 title").font(Font::new().color("#9467bd")))
101+
.title(Title::with_text("yaxis4 title").font(Font::new().color("#9467bd")))
102102
.tick_font(Font::new().color("#9467bd"))
103103
.anchor("free")
104104
.overlaying("y")
105-
.side(Side::Right)
105+
.side(AxisSide::Right)
106106
.position(0.85),
107107
);
108108
plot.set_layout(layout);

docs/book/src/recipes/subplots/subplots.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ fn multiple_custom_sized_subplots(show: bool) {
270270
plot.add_trace(trace4);
271271

272272
let layout = Layout::new()
273-
.title(Title::new("Multiple Custom Sized Subplots"))
273+
.title(Title::with_text("Multiple Custom Sized Subplots"))
274274
.x_axis(Axis::new().domain(&[0., 0.45]).anchor("y1"))
275275
.y_axis(Axis::new().domain(&[0.5, 1.]).anchor("x1"))
276276
.x_axis2(Axis::new().domain(&[0.55, 1.]).anchor("y2"))

0 commit comments

Comments
 (0)