Skip to content

Change Contours size to be f64 instead of usize #245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 12, 2024
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ 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.11.0] - 2024-11-x
### Changed
- [[#245](https://github.com/plotly/plotly.rs/pull/245)] Change Contours size to be `f64` instead of `usize`

## [0.10.1] - 2024-11-x
### Added
- [[#243](https://github.com/plotly/plotly.rs/pull/243)] Made `plotly_embed_js` embed all JS scripts when enabled.
Expand Down
4 changes: 2 additions & 2 deletions docs/book/src/recipes/scientific_charts/contour_plots.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ fn customizing_size_and_range_of_a_contour_plots_contours(show: bool) {
let trace = Contour::new_z(z)
.color_scale(ColorScale::Palette(ColorScalePalette::Jet))
.auto_contour(false)
.contours(Contours::new().start(0.0).end(8.0).size(2));
.contours(Contours::new().start(0.0).end(8.0).size(2.0));

let layout = Layout::new().title(Title::with_text("Customizing Size and Range of Contours"));
let mut plot = Plot::new();
Expand All @@ -136,7 +136,7 @@ fn customizing_size_and_range_of_a_contour_plots_contours(show: bool) {
if (document.getElementById("customizing_size_and_range_of_a_contour_plots_contours")) {
var d3 = Plotly.d3;
var image_element= d3.select('#image-export');
var trace_0 = {"type":"contour","z":[[10.0,10.625,12.5,15.625,20.0],[5.625,6.25,8.125,11.25,15.625],[2.5,3.125,5.0,8.125,12.5],[0.625,1.25,3.125,6.25,10.625],[0.0,0.625,2.5,5.625,10.0]],"colorscale":"Jet","autocontour":false,"contours":{"start":0.0,"end":8.0,"size":2}};
var trace_0 = {"type":"contour","z":[[10.0,10.625,12.5,15.625,20.0],[5.625,6.25,8.125,11.25,15.625],[2.5,3.125,5.0,8.125,12.5],[0.625,1.25,3.125,6.25,10.625],[0.0,0.625,2.5,5.625,10.0]],"colorscale":"Jet","autocontour":false,"contours":{"start":0.0,"end":8.0,"size":2.0}};
var data = [trace_0];
var layout = {"title":{"text":"Customizing Size and Range of Contours"}};
Plotly.newPlot('customizing_size_and_range_of_a_contour_plots_contours', data, layout, {"responsive": true});
Expand Down
2 changes: 1 addition & 1 deletion examples/scientific_charts/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn customizing_size_and_range_of_a_contour_plots_contours() {
let trace = Contour::new_z(z)
.color_scale(ColorScale::Palette(ColorScalePalette::Jet))
.auto_contour(false)
.contours(Contours::new().start(0.0).end(8.0).size(2));
.contours(Contours::new().start(0.0).end(8.0).size(2.0));

let layout = Layout::new().title("Customizing Size and Range of Contours");
let mut plot = Plot::new();
Expand Down
6 changes: 3 additions & 3 deletions plotly/src/traces/contour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub struct Contours {
r#type: Option<ContoursType>,
start: Option<f64>,
end: Option<f64>,
size: Option<usize>,
size: Option<f64>,
coloring: Option<Coloring>,
#[serde(rename = "showlines")]
show_lines: Option<bool>,
Expand Down Expand Up @@ -522,7 +522,7 @@ mod tests {
.type_(ContoursType::Levels)
.start(0.0)
.end(10.0)
.size(5)
.size(5.0)
.coloring(Coloring::HeatMap)
.show_lines(true)
.show_labels(false)
Expand All @@ -535,7 +535,7 @@ mod tests {
"type": "levels",
"start": 0.0,
"end": 10.0,
"size": 5,
"size": 5.0,
"coloring": "heatmap",
"showlines": true,
"showlabels": false,
Expand Down
Loading