Skip to content

Commit e4f02e1

Browse files
committed
fix ScatterPolar example and add it to mdbook
Signed-off-by: Andrei Gherghescu <[email protected]>
1 parent 23e1290 commit e4f02e1

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ https://github.com/plotly/plotly.rs/pull/350
1010
### Fixed
1111

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

1415
### Changed
1516

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ The `to_inline_html` method is used to produce the html plot displayed in this p
3636

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

39+
## Polar Scatter Plots
40+
```rust,no_run
41+
{{#include ../../../../../examples/basic_charts/src/main.rs:polar_scatter_plot}}
42+
```
43+
44+
{{#include ../../../../../examples/basic_charts/output/inline_polar_scatter_plot.html}}
45+
3946

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

69-
{{#include ../../../../../examples/basic_charts/output/inline_large_data_sets.html}}
76+
{{#include ../../../../../examples/basic_charts/output/inline_large_data_sets.html}}

examples/basic_charts/src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ fn bubble_scatter_plots(show: bool, file_name: &str) {
104104
}
105105
// ANCHOR_END: bubble_scatter_plots
106106

107+
// ANCHOR: polar_scatter_plot
107108
fn polar_scatter_plot(show: bool, file_name: &str) {
108109
let n: usize = 400;
109110
let theta: Vec<f64> = Array::linspace(0., 360., n).into_raw_vec_and_offset().0;
@@ -148,6 +149,7 @@ fn polar_scatter_plot(show: bool, file_name: &str) {
148149
plot.show_html(path);
149150
}
150151
}
152+
// ANCHOR_END: polar_scatter_plot
151153

152154
// ANCHOR: data_labels_hover
153155
fn data_labels_hover(show: bool, file_name: &str) {

plotly/src/layout/polar.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,6 @@ pub struct AutoRangeOptions {
358358
include: Option<Vec<NumOrString>>,
359359
}
360360

361-
impl AutoRangeOptions {
362-
/// Create a new set of autorange options with default settings.
363-
pub fn new() -> Self {
364-
Default::default()
365-
}
366-
}
367-
368361
/// Setting [`AutoTypeNumbers::Strict`] prevents Plotly from coercing numeric
369362
/// strings in trace data into numbers. This may affect the inferred
370363
/// [`axis_type`](RadialAxis::axis_type). Coercing/converting is the default
@@ -477,9 +470,10 @@ pub enum PolarTickMode {
477470
/// [`axis_type`](RadialAxis::axis_type) is [`RadialAxisType::Log`] then
478471
/// you must take the log of your starting tick. For example, to set the
479472
/// starting tick to 100, set [`tick_0`](PolarTickMode::Linear::tick_0)
480-
/// to 2 (except when [`d_tick`](PolarTickMode::Linear::d_tick) = *L<f>*
481-
/// (see [`d_tick`](PolarTickMode::Linear::d_tick) for more
482-
/// information). If the [`axis_type`](RadialAxis::axis_type) is
473+
/// to 2 (except when [`d_tick`](PolarTickMode::Linear::d_tick) =
474+
/// "L\<f\>" (see [`d_tick`](PolarTickMode::Linear::d_tick) for
475+
/// more information). If the
476+
/// [`axis_type`](RadialAxis::axis_type) is
483477
/// [`RadialAxisType::Date`], it should be a date string. If the
484478
/// [`axis_type`](RadialAxis::axis_type) is [`RadialAxisType::Category`]
485479
/// or [`AngularAxisType::Category`] then supply an integer, which will
@@ -496,7 +490,7 @@ pub enum PolarTickMode {
496490
///
497491
/// [`RadialAxisType::Log`] has several special values:
498492
///
499-
/// - *L<f>*, where `f` is a positive number, gives ticks linearly
493+
/// - "L\<f\>", where `f` is a positive number, gives ticks linearly
500494
/// spaced in value (but not position). For example,
501495
/// [`tick_0`](PolarTickMode::Linear::tick_0) = 0.1,
502496
/// [`d_tick`](PolarTickMode::Linear::d_tick) = *L0.5* will put ticks
@@ -511,7 +505,7 @@ pub enum PolarTickMode {
511505
///
512506
/// [`RadialAxisType::Date`] also has special values:
513507
///
514-
/// - *M<n>* gives ticks spaced by a number of months, where `n` is a
508+
/// - "M\<n\>" gives ticks spaced by a number of months, where `n` is a
515509
/// positive integer. To set ticks on the 15th of every third month,
516510
/// set [`tick_0`](PolarTickMode::Linear::tick_0) to *2000-01-15* and
517511
/// [`d_tick`](PolarTickMode::Linear::d_tick) to *M3*. To set ticks
@@ -582,7 +576,7 @@ mod tests {
582576
.visible(true)
583577
.axis_type(RadialAxisType::Linear)
584578
.auto_type_numbers(AutoTypeNumbers::Strict)
585-
.auto_range_options(AutoRangeOptions::new().min_allowed(1))
579+
.auto_range_options(AutoRangeOptions::default().min_allowed(1))
586580
.auto_range(AutoRange::Bool(true))
587581
.range_mode(RangeMode::Normal)
588582
.min_allowed(0_u32)

0 commit comments

Comments
 (0)