Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ https://github.com/plotly/plotly.rs/pull/350
### Fixed

- [[#348](https://github.com/plotly/plotly.rs/pull/348)] Fix Pie chart color setting
- [[#355](https://github.com/plotly/plotly.rs/pull/355)] Add LayoutPolar support

### Changed

Expand Down
9 changes: 8 additions & 1 deletion docs/book/src/recipes/basic_charts/scatter_plots.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ The `to_inline_html` method is used to produce the html plot displayed in this p

{{#include ../../../../../examples/basic_charts/output/inline_bubble_scatter_plots.html}}

## Polar Scatter Plots
```rust,no_run
{{#include ../../../../../examples/basic_charts/src/main.rs:polar_scatter_plot}}
```

{{#include ../../../../../examples/basic_charts/output/inline_polar_scatter_plot.html}}


## Data Labels Hover
```rust,no_run
Expand Down Expand Up @@ -66,4 +73,4 @@ The `to_inline_html` method is used to produce the html plot displayed in this p
{{#include ../../../../../examples/basic_charts/src/main.rs:large_data_sets}}
```

{{#include ../../../../../examples/basic_charts/output/inline_large_data_sets.html}}
{{#include ../../../../../examples/basic_charts/output/inline_large_data_sets.html}}
28 changes: 27 additions & 1 deletion examples/basic_charts/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use plotly::{
Marker, Mode, Orientation, Pattern, PatternShape,
},
layout::{
Annotation, Axis, AxisRange, BarMode, CategoryOrder, Layout, LayoutGrid, Legend,
AngularAxis, Annotation, Axis, AxisRange, BarMode, CategoryOrder, Layout, LayoutGrid,
LayoutPolar, Legend, PolarAxisAttributes, PolarAxisTicks, PolarDirection, RadialAxis,
TicksDirection, TraceOrder,
},
sankey::{Line as SankeyLine, Link, Node},
Expand Down Expand Up @@ -103,6 +104,7 @@ fn bubble_scatter_plots(show: bool, file_name: &str) {
}
// ANCHOR_END: bubble_scatter_plots

// ANCHOR: polar_scatter_plot
fn polar_scatter_plot(show: bool, file_name: &str) {
let n: usize = 400;
let theta: Vec<f64> = Array::linspace(0., 360., n).into_raw_vec_and_offset().0;
Expand All @@ -119,11 +121,35 @@ fn polar_scatter_plot(show: bool, file_name: &str) {
let mut plot = Plot::new();
plot.add_trace(trace);

let ticks = PolarAxisTicks::new().tick_color("#222222");

let axis_attributes = PolarAxisAttributes::new()
.grid_color("#888888")
.ticks(ticks);

let radial_axis = RadialAxis::new()
.title("My Title")
.axis_attributes(axis_attributes.clone());

let angular_axis = AngularAxis::new()
.direction(PolarDirection::Clockwise)
.rotation(45.0)
.axis_attributes(axis_attributes);

let layout_polar = LayoutPolar::new()
.bg_color("#eeeeee")
.radial_axis(radial_axis)
.angular_axis(angular_axis);

let layout = Layout::new().polar(layout_polar);
plot.set_layout(layout);

let path = write_example_to_html(&plot, file_name);
if show {
plot.show_html(path);
}
}
// ANCHOR_END: polar_scatter_plot

// ANCHOR: data_labels_hover
fn data_labels_hover(show: bool, file_name: &str) {
Expand Down
8 changes: 7 additions & 1 deletion plotly/src/layout/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ mod grid;
mod legend;
mod mapbox;
mod modes;
mod polar;
mod rangebreaks;
mod scene;
mod shape;
Expand All @@ -42,6 +43,11 @@ pub use self::mapbox::{Center, Mapbox, MapboxStyle};
pub use self::modes::{
AspectMode, BarMode, BarNorm, BoxMode, ClickMode, UniformTextMode, ViolinMode, WaterfallMode,
};
pub use self::polar::{
AngularAxis, AngularAxisType, AutoRange, AutoRangeOptions, AutoTypeNumbers, AxisLayer,
GridShape, Hole, LayoutPolar, MinorLogLabels, PolarAxisAttributes, PolarAxisTicks,
PolarDirection, PolarTickMode, RadialAxis, RadialAxisType, ThetaUnit,
};
pub use self::rangebreaks::RangeBreak;
pub use self::scene::{
AspectRatio, Camera, CameraCenter, DragMode, DragMode3D, Eye, HoverMode, LayoutScene,
Expand Down Expand Up @@ -330,7 +336,7 @@ pub struct LayoutFields {
// ternary: Option<LayoutTernary>,
scene: Option<LayoutScene>,
geo: Option<LayoutGeo>,
// polar: Option<LayoutPolar>,
polar: Option<LayoutPolar>,
annotations: Option<Vec<Annotation>>,
shapes: Option<Vec<Shape>>,
#[serde(rename = "newshape")]
Expand Down
Loading
Loading