Skip to content

Commit

Permalink
Merge branch 'main' into multiples-axis
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-ng authored Sep 6, 2024
2 parents 3e910b2 + 7bfae55 commit 5fcea76
Show file tree
Hide file tree
Showing 31 changed files with 99 additions and 90 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ All notable changes to this project will be documented in this file.

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).

## [0.9.1] - 2024-09-06
### Added
- [[#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
- [[#227](https://github.com/plotly/plotly.rs/pull/227)] Switch from HTML template render from `askama` to `rinja`

### Fixed
- [[#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`
- [[#233](https://github.com/plotly/plotly.rs/pull/233)] Fix mdBook code examples

## [0.9.0] - 2024-06-29
### Added
- [[#153](https://github.com/plotly/plotly.rs/pull/153)] Added `LayoutScene`.
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Add this to your `Cargo.toml`:

```toml
[dependencies]
plotly = "0.9.0"
plotly = "0.9.1"
```

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

[dependencies]
plotly = { version = "0.9.0", features = ["kaleido"] }
plotly = { version = "0.9.1", features = ["kaleido"] }
```

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.
Expand All @@ -130,7 +130,7 @@ Using `Plotly.rs` in a Wasm-based frontend framework is possible by enabling the
# Cargo.toml

[dependencies]
plotly = { version = "0.9.0", features = ["wasm"] }
plotly = { version = "0.9.1", features = ["wasm"] }
```

First, make sure that you have the Plotly JavaScript library in your base HTML template:
Expand Down
2 changes: 1 addition & 1 deletion docs/book/src/fundamentals/shapes.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use plotly::layout::{
Axis, GridPattern, Layout, LayoutGrid, Margin, Shape, ShapeLayer, ShapeLine,
ShapeType,
};
use plotly::{Bar, NamedColor, Plot, Scatter};
use plotly::{Bar, color::NamedColor, Plot, Scatter};
use rand::thread_rng;
use rand_distr::{Distribution, Normal};
```
Expand Down
4 changes: 2 additions & 2 deletions docs/book/src/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ To start using [plotly.rs](https://github.com/plotly/plotly.rs) in your project

```toml
[dependencies]
plotly = "0.9.0"
plotly = "0.9.1"
```

[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.
Expand Down Expand Up @@ -97,7 +97,7 @@ To add the ability to save plots in the following formats: png, jpeg, webp, svg,

```toml
[dependencies]
plotly = { version = "0.9.0", features = ["kaleido"] }
plotly = { version = "0.9.1", features = ["kaleido"] }
```

## WebAssembly Support
Expand Down
8 changes: 4 additions & 4 deletions docs/book/src/recipes/basic_charts/bar_charts.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ use plotly::common::{
ColorScale, ColorScalePalette, DashType, Fill, Font, Line, LineShape, Marker, Mode, Title,
};
use plotly::layout::{Axis, BarMode, Layout, Legend, TicksDirection};
use plotly::{Bar, NamedColor, Plot, Rgb, Rgba, Scatter};
use plotly::{Bar, color::{NamedColor, Rgb, Rgba}, Plot, Scatter};
use rand_distr::{Distribution, Normal, Uniform};
```

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


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

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


## Stacked Bar Chart
```rust
```rust
fn stacked_bar_chart(show: bool) {
let animals1 = vec!["giraffes", "orangutans", "monkeys"];
let trace1 = Bar::new(animals1, vec![20, 14, 23]).name("SF Zoo");
Expand Down
8 changes: 4 additions & 4 deletions docs/book/src/recipes/basic_charts/line_charts.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use plotly::common::{
ColorScale, ColorScalePalette, DashType, Fill, Font, Line, LineShape, Marker, Mode, Title,
};
use plotly::layout::{Axis, BarMode, Layout, Legend, TicksDirection};
use plotly::{Bar, NamedColor, Plot, Rgb, Rgba, Scatter};
use plotly::{Bar, color::{NamedColor, Rgb, Rgba}, Plot, Scatter};
use rand_distr::{Distribution, Normal, Uniform};
```

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

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

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

let layout = Layout::new()
.title(Title::new("Styling Line Plot"))
.title(Title::with_text("Styling Line Plot"))
.width(500)
.height(500);
let mut plot = Plot::new();
Expand Down
16 changes: 8 additions & 8 deletions docs/book/src/recipes/basic_charts/scatter_plots.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use plotly::common::{
ColorScale, ColorScalePalette, DashType, Fill, Font, Line, LineShape, Marker, Mode, Title,
};
use plotly::layout::{Axis, BarMode, Layout, Legend, TicksDirection};
use plotly::{Bar, NamedColor, Plot, Rgb, Rgba, Scatter};
use plotly::{Bar, color::{NamedColor, Rgb, Rgba}, Plot, Scatter};
use rand_distr::{Distribution, Normal, Uniform};
```

Expand Down Expand Up @@ -156,9 +156,9 @@ fn data_labels_hover(show: bool) {
plot.add_trace(trace2);

let layout = Layout::new()
.title(Title::new("Data Labels Hover"))
.x_axis(Axis::new().title(Title::new("x")).range(vec![0.75, 5.25]))
.y_axis(Axis::new().title(Title::new("y")).range(vec![0., 8.]));
.title(Title::with_text("Data Labels Hover"))
.x_axis(Axis::new().title(Title::with_text("x")).range(vec![0.75, 5.25]))
.y_axis(Axis::new().title(Title::with_text("y")).range(vec![0., 8.]));
plot.set_layout(layout);
if show {
plot.show();
Expand Down Expand Up @@ -201,7 +201,7 @@ fn data_labels_on_the_plot(show: bool) {
plot.add_trace(trace2);

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

let layout = Layout::new()
.title(Title::new("Quarter 1 Growth"))
.title(Title::with_text("Quarter 1 Growth"))
.x_axis(
Axis::new()
.title(Title::new("GDP per Capita"))
.title(Title::with_text("GDP per Capita"))
.show_grid(false)
.zero_line(false),
)
.y_axis(Axis::new().title(Title::new("Percent")).show_line(false));
.y_axis(Axis::new().title(Title::with_text("Percent")).show_line(false));
let mut plot = Plot::new();
plot.add_trace(trace1);
plot.add_trace(trace2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn time_series_plot_with_custom_date_range(show: bool) {

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

if show {
Expand Down Expand Up @@ -68,7 +68,7 @@ fn time_series_with_range_slider(show: bool) {

let layout = Layout::new()
.x_axis(Axis::new().range_slider(RangeSlider::new().visible(true)))
.title(Title::new("Manually Set Date Range"));
.title(Title::with_text("Manually Set Date Range"));
plot.set_layout(layout);

if show {
Expand Down
6 changes: 3 additions & 3 deletions docs/book/src/recipes/scientific_charts/contour_plots.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn colorscale_for_contour_plot(show: bool) {
];
let trace = Contour::new_z(z).color_scale(ColorScale::Palette(ColorScalePalette::Jet));

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

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

let layout = Layout::new().title(Title::new("Customizing Size and Range of Contours"));
let layout = Layout::new().title(Title::with_text("Customizing Size and Range of Contours"));
let mut plot = Plot::new();
plot.set_layout(layout);
plot.add_trace(trace);
Expand Down
12 changes: 6 additions & 6 deletions docs/book/src/recipes/statistical_charts/box_plots.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use plotly::box_plot::{BoxMean, BoxPoints};
use plotly::common::{ErrorData, ErrorType, Line, Marker, Mode, Orientation, Title};
use plotly::histogram::{Bins, Cumulative, HistFunc, HistNorm};
use plotly::layout::{Axis, BarMode, BoxMode, Layout, Margin};
use plotly::{Bar, BoxPlot, Histogram, NamedColor, Plot, Rgb, Rgba, Scatter};
use plotly::{Bar, BoxPlot, Histogram, color::{NamedColor, Rgb, Rgba}, Scatter};
use rand_distr::{Distribution, Normal, Uniform};

```
Expand Down Expand Up @@ -156,7 +156,7 @@ fn grouped_box_plot(show: bool) {
let layout = Layout::new()
.y_axis(
Axis::new()
.title(Title::new("normalized moisture"))
.title(Title::with_text("normalized moisture"))
.zero_line(false),
)
.box_mode(BoxMode::Group);
Expand Down Expand Up @@ -222,7 +222,7 @@ fn box_plot_styling_outliers(show: bool) {
.marker(Marker::new().color(Rgb::new(107, 174, 214)))
.box_points(BoxPoints::Outliers);

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

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

let mut plot = Plot::new();
plot.set_layout(layout);
Expand Down Expand Up @@ -341,10 +341,10 @@ fn grouped_horizontal_box_plot(show: bool) {
plot.add_trace(trace3);

let layout = Layout::new()
.title(Title::new("Grouped Horizontal Box Plot"))
.title(Title::with_text("Grouped Horizontal Box Plot"))
.x_axis(
Axis::new()
.title(Title::new("normalized moisture"))
.title(Title::with_text("normalized moisture"))
.zero_line(false),
)
.box_mode(BoxMode::Group);
Expand Down
2 changes: 1 addition & 1 deletion docs/book/src/recipes/statistical_charts/error_bars.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use plotly::box_plot::{BoxMean, BoxPoints};
use plotly::common::{ErrorData, ErrorType, Line, Marker, Mode, Orientation, Title};
use plotly::histogram::{Bins, Cumulative, HistFunc, HistNorm};
use plotly::layout::{Axis, BarMode, BoxMode, Layout, Margin};
use plotly::{Bar, BoxPlot, Histogram, NamedColor, Plot, Rgb, Rgba, Scatter};
use plotly::{Bar, BoxPlot, Histogram, Plot, color::{NamedColor, Rgb, Rgba}, Scatter};
use rand_distr::{Distribution, Normal, Uniform};

```
Expand Down
8 changes: 4 additions & 4 deletions docs/book/src/recipes/statistical_charts/histograms.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use plotly::box_plot::{BoxMean, BoxPoints};
use plotly::common::{ErrorData, ErrorType, Line, Marker, Mode, Orientation, Title};
use plotly::histogram::{Bins, Cumulative, HistFunc, HistNorm};
use plotly::layout::{Axis, BarMode, BoxMode, Layout, Margin};
use plotly::{Bar, BoxPlot, Histogram, NamedColor, Plot, Rgb, Rgba, Scatter};
use plotly::{Bar, BoxPlot, Histogram, Plot, color::{NamedColor, Rgb, Rgba}, Scatter};
use rand_distr::{Distribution, Normal, Uniform};

```
Expand Down Expand Up @@ -201,9 +201,9 @@ fn colored_and_styled_histograms(show: bool) {
.auto_bin_x(false)
.x_bins(Bins::new(-3.2, 4.0, 0.06));
let layout = Layout::new()
.title(Title::new("Sampled Results"))
.x_axis(Axis::new().title(Title::new("Value")))
.y_axis(Axis::new().title(Title::new("Count")))
.title(Title::with_text("Sampled Results"))
.x_axis(Axis::new().title(Title::with_text("Value")))
.y_axis(Axis::new().title(Title::with_text("Count")))
.bar_mode(BarMode::Overlay)
.bar_gap(0.05)
.bar_group_gap(0.2);
Expand Down
26 changes: 13 additions & 13 deletions docs/book/src/recipes/subplots/multiple_axes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The following imports have been used to produce the plots below:

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

let layout = Layout::new()
.title(Title::new("Double Y Axis Example"))
.y_axis(Axis::new().title(Title::new("yaxis title")))
.title(Title::with_text("Double Y Axis Example"))
.y_axis(Axis::new().title(Title::with_text("yaxis title")))
.y_axis2(
Axis::new()
.title(Title::new("yaxis2 title").font(Font::new().color(Rgb::new(148, 103, 189))))
.title(Title::with_text("yaxis2 title").font(Font::new().color(Rgb::new(148, 103, 189))))
.tick_font(Font::new().color(Rgb::new(148, 103, 189)))
.overlaying("y")
.side(Side::Right),
.side(AxisSide::Right),
);
plot.set_layout(layout);
if show {
Expand Down Expand Up @@ -71,38 +71,38 @@ fn multiple_axes(show: bool) {
plot.add_trace(trace4);

let layout = Layout::new()
.title(Title::new("multiple y-axes example"))
.title(Title::with_text("multiple y-axes example"))
.width(800)
.x_axis(Axis::new().domain(&[0.3, 0.7]))
.y_axis(
Axis::new()
.title(Title::new("yaxis title").font(Font::new().color("#1f77b4")))
.title(Title::with_text("yaxis title").font(Font::new().color("#1f77b4")))
.tick_font(Font::new().color("#1f77b4")),
)
.y_axis2(
Axis::new()
.title(Title::new("yaxis2 title").font(Font::new().color("#ff7f0e")))
.title(Title::with_text("yaxis2 title").font(Font::new().color("#ff7f0e")))
.tick_font(Font::new().color("#ff7f0e"))
.anchor("free")
.overlaying("y")
.side(Side::Left)
.side(AxisSide::Left)
.position(0.15),
)
.y_axis3(
Axis::new()
.title(Title::new("yaxis3 title").font(Font::new().color("#d62728")))
.title(Title::with_text("yaxis3 title").font(Font::new().color("#d62728")))
.tick_font(Font::new().color("#d62728"))
.anchor("x")
.overlaying("y")
.side(Side::Right),
.side(AxisSide::Right),
)
.y_axis4(
Axis::new()
.title(Title::new("yaxis4 title").font(Font::new().color("#9467bd")))
.title(Title::with_text("yaxis4 title").font(Font::new().color("#9467bd")))
.tick_font(Font::new().color("#9467bd"))
.anchor("free")
.overlaying("y")
.side(Side::Right)
.side(AxisSide::Right)
.position(0.85),
);
plot.set_layout(layout);
Expand Down
2 changes: 1 addition & 1 deletion docs/book/src/recipes/subplots/subplots.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ fn multiple_custom_sized_subplots(show: bool) {
plot.add_trace(trace4);

let layout = Layout::new()
.title(Title::new("Multiple Custom Sized Subplots"))
.title(Title::with_text("Multiple Custom Sized Subplots"))
.x_axis(Axis::new().domain(&[0., 0.45]).anchor("y1"))
.y_axis(Axis::new().domain(&[0.5, 1.]).anchor("x1"))
.x_axis2(Axis::new().domain(&[0.55, 1.]).anchor("y2"))
Expand Down
Loading

0 comments on commit 5fcea76

Please sign in to comment.