Skip to content

Commit

Permalink
Merge branch 'release' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Axect committed Mar 11, 2024
2 parents d98d12c + 6457b0b commit c494d1a
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "peroxide"
version = "0.34.6"
version = "0.34.7"
authors = ["axect <[email protected]>"]
edition = "2018"
description = "Rust comprehensive scientific computation library contains linear algebra, numerical analysis, statistics and machine learning tools with farmiliar syntax"
Expand All @@ -20,7 +20,7 @@ maintenance = { status = "actively-developed" }
float-cmp = "0.9"

[dependencies]
csv = { version = "1.1", optional = true, default_features = false }
csv = { version = "1", optional = true, default_features = false }
rand = "0.8"
rand_distr = "0.4"
order-stat = "0.1"
Expand Down
18 changes: 18 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# Release 0.34.7 (2024-03-11)

## More updates for `plot` feature

- Make legend optional (Now, no legend is available)
- Implement `set_line_style`. Here are available line styles.
- `LineStyle::Solid`
- `LineStyle::Dashed`
- `LineStyle::Dotted`
- `LineStyle::DashDot`
- Implement `set_color`
- Implement `set_alpha`
- More markers.

## Getter for ODE

- Add explicit getter for `ExplicitODE` and `ImplicitODE` for various fields.

# Release 0.34.6 (2024-03-01)

## Big updates for `plot` feature
Expand Down
40 changes: 31 additions & 9 deletions src/util/plot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,36 @@
//!
//! ![test_plot](https://raw.githubusercontent.com/Axect/Peroxide/master/example_data/test_plot.png)
//!
//! But now, the recommended way is exporting `netcdf` files. Refer to [dataframe](../../structure/dataframe/index.html)
//! # Available Plot Options
//! - `set_domain` : Set x data
//! - `insert_image` : Insert y data
//! - `insert_pair` : Insert (x, y) data
//! - `set_title` : Set title of plot (optional)
//! - `set_xlabel` : Set xlabel of plot (optional)
//! - `set_ylabel` : Set ylabel of plot (optional)
//! - `set_zlabel` : Set zlabel of plot (optional; for 3D plot)
//! - `set_xscale` : Set xscale of plot (optional; `PlotScale::Linear` or `PlotScale::Log`)
//! - `set_yscale` : Set yscale of plot (optional; `PlotScale::Linear` or `PlotScale::Log`)
//! - `set_xlim` : Set xlim of plot (optional)
//! - `set_ylim` : Set ylim of plot (optional)
//! - `set_legend` : Set legend of plot (optional)
//! - `set_path` : Set path of plot (with filename - e.g. "example_data/test_plot.png")
//! - `set_fig_size` : Set figure size of plot (optional)
//! - `set_dpi` : Set dpi of plot (optional)
//! - `grid` : Set grid of plot (Grid::On, Grid::Off (default))
//! - `set_marker` : Set marker of plot (optional; `Markers::{Point, Line, Circle, TriangleUp, ...}`)
//! - `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>)
//! - `savefig` : Save plot with given path
extern crate pyo3;
use self::pyo3::types::IntoPyDict;
use self::pyo3::{PyResult, Python};
pub use self::Grid::{Off, On};
pub use self::Markers::{Circle, Line, Point};
use self::PlotOptions::{Domain, Images, Legends, Pairs, Path};
use self::PlotOptions::{Domain, Images, Pairs, Path};
use std::collections::HashMap;
use std::fmt::Display;

Expand Down Expand Up @@ -515,13 +537,13 @@ impl Plot for Plot2D {
style
),
};
if let Some(fs) = fig_size {
plot_string.push_str(&format!("plt.figure(figsize=fs, dpi=dp)\n")[..]);
if fig_size.is_some() {
plot_string.push_str(&"plt.figure(figsize=fs, dpi=dp)\n".to_string()[..]);
} else {
plot_string.push_str(&format!("plt.figure()\n")[..]);
plot_string.push_str(&"plt.figure()\n".to_string()[..]);
}
if self.tight {
plot_string.push_str(&format!("plt.autoscale(tight=True)\n")[..]);
plot_string.push_str(&"plt.autoscale(tight=True)\n".to_string()[..]);
}
if let Some(t) = title {
plot_string.push_str(&format!("plt.title(r\"{}\")\n", t)[..]);
Expand All @@ -540,10 +562,10 @@ impl Plot for Plot2D {
PlotScale::Linear => plot_string.push_str(&"plt.yscale(\"linear\")\n".to_string()[..]),
PlotScale::Log => plot_string.push_str(&"plt.yscale(\"log\")\n".to_string()[..]),
}
if let Some(xl) = self.xlim {
if self.xlim.is_some() {
plot_string.push_str(&"plt.xlim(xl)\n".to_string()[..]);
}
if let Some(yl) = self.ylim {
if self.ylim.is_some() {
plot_string.push_str(&"plt.ylim(yl)\n".to_string()[..]);
}

Expand Down

0 comments on commit c494d1a

Please sign in to comment.