Skip to content

Commit

Permalink
DOCS: Add scatter to plot example
Browse files Browse the repository at this point in the history
  • Loading branch information
Axect committed Mar 29, 2024
1 parent 329688f commit 128224e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Binary file modified example_data/test_plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 12 additions & 4 deletions src/util/plot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,20 @@
//! let y1 = x.fmap(|t| t.powi(2));
//! let y2 = x.fmap(|t| t.powi(3));
//!
//! let normal = Normal(0f64, 0.1);
//! let eps = normal.sample(100);
//! let y3 = y2.add_v(&eps);
//!
//! let mut plt = Plot2D::new();
//! plt.set_domain(x)
//! .insert_image(y1)
//! .insert_image(y2)
//! .set_legend(vec![r"$y=x^2$", r"$y=x^3$"])
//! .insert_image(y3)
//! .set_legend(vec![r"$y=x^2$", r"$y=x^3$", r"$y=x^2 + \epsilon$"])
//! .set_line_style(vec![(0, LineStyle::Dashed), (1, LineStyle::Dotted)])
//! .set_color(vec![(0, "red"), (1, "darkblue")])
//! .set_plot_type(vec![(2, PlotType::Scatter)])
//! .set_marker(vec![(2, Markers::Point)])
//! .set_color(vec![(0, "red"), (1, "darkblue"), (2, "olive")])
//! .set_xlabel(r"$x$")
//! .set_ylabel(r"$y$")
//! .set_style(PlotStyle::Nature) // if you want to use scienceplots
Expand Down Expand Up @@ -63,8 +70,9 @@
//! - `set_style` : Set style of plot (`PlotStyle::Nature`, `PlotStyle::IEEE`, `PlotStyle::Default` (default), `PlotStyle::Science`)
//! - `tight_layout` : Set tight layout of plot (optional)
//! - `set_line_style` : Set line style of plot (optional; `LineStyle::{Solid, Dashed, Dotted, DashDot}`)
//! - `set_color` : Set color of plot (optional; Vec<&str>)
//! - `set_alpha` : Set alpha of plot (optional; Vec<f64>)
//! - `set_color` : Set color of plot (optional; Vec<(usize, &str)>)
//! - `set_alpha` : Set alpha of plot (optional; Vec<(usize, f64)>)
//! - `set_plot_type` : Set plot type of plot (optional; `PlotType::{Scatter, Line, Bar}`)
//! - `savefig` : Save plot with given path
extern crate pyo3;
Expand Down

0 comments on commit 128224e

Please sign in to comment.