Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9ac2764
Add comment
cpmech Feb 8, 2025
d63cd80
Draft Util struct
cpmech Feb 8, 2025
f5eafae
Add test
cpmech Feb 8, 2025
01d7dd5
[wip] Impl InsetAxes
cpmech Feb 8, 2025
32dc86d
Add tests
cpmech Feb 8, 2025
ad996ad
Remove Util
cpmech Feb 8, 2025
ed7da4e
[wip] Test InsetAxes
cpmech Feb 8, 2025
79d535f
Improve InsetAxes
cpmech Feb 9, 2025
ec05a0c
feat: add styling options for inset axes indicators and borders
cpmech Feb 9, 2025
32c3552
Ignore aider config
cpmech Feb 9, 2025
000ad75
refactor: remove border styling from InsetAxes
cpmech Feb 9, 2025
d01e2a9
refactor: remove background_color from InsetAxes
cpmech Feb 9, 2025
c9f66ae
Fix aider's mistakes
cpmech Feb 9, 2025
c1a4938
feat: add indicator line width support to InsetAxes
cpmech Feb 9, 2025
5419c53
Improve setting options for the indicator in InsetAxes
cpmech Feb 9, 2025
fa96c1e
Impl set indicator alpha
cpmech Feb 9, 2025
17c111d
feat: Add hide_ticks method to InsetAxes to remove axis ticks
cpmech Feb 9, 2025
bdd7c51
feat: Add set_axes_visibility method with visibility state to InsetAxes
cpmech Feb 9, 2025
3195a04
refactor: Move axes visibility logic from `set_axes_visibility` to `o…
cpmech Feb 9, 2025
8119b46
Fix setting of axes visibility
cpmech Feb 9, 2025
8f1e74b
feat: Add title setting functionality for inset axes
cpmech Feb 9, 2025
14a135f
Improve testing of InsetAxes
cpmech Feb 9, 2025
2a4de70
Update test figure
cpmech Feb 9, 2025
114edbe
test: Add comprehensive unit tests for InsetAxes struct
cpmech Feb 9, 2025
46909cb
test: add barplot test case to test_inset_axes.rs
cpmech Feb 9, 2025
a151864
Handle Barplot in InsetAxes
cpmech Feb 9, 2025
0d49287
(no commit message provided)
cpmech Feb 9, 2025
b816566
Handle Curve in InsetAxes. Improve doc examples
cpmech Feb 9, 2025
db0498e
Add test
cpmech Feb 9, 2025
da1b0c9
Handle Contour in InsetAxes
cpmech Feb 9, 2025
3b4ee03
Handle Histogram in InsetAxes
cpmech Feb 9, 2025
e255f83
Handle text in InsetAxes
cpmech Feb 9, 2025
d3558b2
Improve examples Readme
cpmech Feb 9, 2025
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
rust_modules
/target
Cargo.lock
call_python3_works.py
call_python3_works.py
.aider*
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"CARETRIGHTBASE",
"CARETUP",
"CARETUPBASE",
"cbook",
"clabel",
"CLOSEPOLY",
"cmap",
Expand All @@ -51,6 +52,7 @@
"hspace",
"imshow",
"joinstyle",
"kwargs",
"labelcolor",
"labelpad",
"labelsize",
Expand Down
70 changes: 51 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- [Curve](#curve)
- [Histogram](#histogram)
- [Image](#image)
- [InsetAxes](#insetaxes)
- [Surface](#surface)
- [Text](#text)

Expand Down Expand Up @@ -126,8 +127,9 @@ fn main() -> Result<(), StrError> {
plot.set_inv_y()
.add(&bar)
.set_title("Fruits")
.set_label_x("price")
.save("/tmp/plotpy/doc_tests/doc_barplot_3.svg")?;
.set_label_x("price");

// plot.save("/tmp/plotpy/doc_tests/doc_barplot_3.svg")?;
Ok(())
}
```
Expand Down Expand Up @@ -166,8 +168,9 @@ fn main() -> Result<(), StrError> {
let mut plot = Plot::new();
plot.add(&boxes)
.set_title("boxplot documentation test")
.set_ticks_x_labels(&ticks, &labels)
.save("/tmp/plotpy/doc_tests/doc_boxplot_2.svg")?;
.set_ticks_x_labels(&ticks, &labels);

// plot.save("/tmp/plotpy/doc_tests/doc_boxplot_2.svg")?;
Ok(())
}
```
Expand Down Expand Up @@ -216,7 +219,8 @@ fn main() -> Result<(), StrError> {
.set_hide_axes(true)
.set_equal_axes(true)
.set_show_errors(true);
plot.save("/tmp/plotpy/doc_tests/doc_canvas_polycurve.svg")?;

// plot.save("/tmp/plotpy/doc_tests/doc_canvas_polycurve.svg")?;
Ok(())
}
```
Expand Down Expand Up @@ -249,11 +253,10 @@ fn main() -> Result<(), StrError> {

// add contour to plot
let mut plot = Plot::new();
plot.add(&contour);
plot.set_labels("x", "y");
plot.add(&contour)
.set_labels("x", "y");

// save figure
plot.save("/tmp/plotpy/readme_contour.svg")?;
// plot.save("/tmp/plotpy/readme_contour.svg")?;
Ok(())
}
```
Expand Down Expand Up @@ -294,10 +297,11 @@ fn main() -> Result<(), StrError> {

// add curve to plot
let mut plot = Plot::new();
plot.add(&curve).set_num_ticks_y(11).grid_labels_legend("x", "y");
plot.add(&curve)
.set_num_ticks_y(11)
.grid_labels_legend("x", "y");

// save figure
plot.save("/tmp/plotpy/doc_tests/doc_curve.svg")?;
// plot.save("/tmp/plotpy/doc_tests/doc_curve.svg")?;
Ok(())
}
```
Expand Down Expand Up @@ -337,8 +341,7 @@ fn main() -> Result<(), StrError> {
.set_frame_border(true, false, true, false)
.grid_labels_legend("values", "count");

// save figure
plot.save("/tmp/plotpy/doc_tests/doc_histogram.svg")?;
// plot.save("/tmp/plotpy/doc_tests/doc_histogram.svg")?;
Ok(())
}
```
Expand Down Expand Up @@ -370,14 +373,43 @@ fn main() -> Result<(), StrError> {
// save figure
let mut plot = Plot::new();
plot.add(&img);
plot.save("/tmp/plotpy/doc_tests/doc_image_1.svg")?;

// plot.save("/tmp/plotpy/doc_tests/doc_image_1.svg")?;
Ok(())
}
```

![image](https://raw.githubusercontent.com/cpmech/plotpy/main/figures/doc_image_1.svg)


### InsetAxes

```rust
use plotpy::{Curve, InsetAxes, Plot, StrError};

fn main() -> Result<(), StrError> {
// draw curve
let mut curve = Curve::new();
curve.draw(&[0.0, 1.0, 2.0], &[0.0, 1.0, 4.0]);

// allocate inset and add curve to it
let mut inset = InsetAxes::new();
inset
.add(&curve) // add curve to inset
.set_range(0.5, 1.5, 0.5, 1.5) // set the range of the inset
.draw(0.5, 0.5, 0.4, 0.3);

// add curve and inset to plot
let mut plot = Plot::new();
plot.add(&curve)
.set_range(0.0, 5.0, 0.0, 5.0)
.add(&inset); // IMPORTANT: add inset after setting the range

// plot.save("/tmp/plotpy/doc_tests/doc_inset_axes_add.svg")?;
Ok(())
}
```


### Surface

Expand Down Expand Up @@ -432,8 +464,9 @@ fn main() -> Result<(), StrError> {

// save figure
plot.set_equal_axes(true)
.set_figure_size_points(600.0, 600.0)
.save("/tmp/plotpy/readme_superquadric.svg")?;
.set_figure_size_points(600.0, 600.0);

// plot.save("/tmp/plotpy/readme_superquadric.svg")?;
Ok(())
}
```
Expand Down Expand Up @@ -467,8 +500,7 @@ fn main() -> Result<(), StrError> {
let mut plot = Plot::new();
plot.add(&text);

// save figure
plot.save("/tmp/plotpy/doc_tests/doc_text.svg")?;
// plot.save("/tmp/plotpy/doc_tests/doc_text.svg")?;
Ok(())
}
```
Expand Down
31 changes: 30 additions & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
# Examples
# Examples <!-- omit from toc -->

Please check out [the documentation](https://docs.rs/plotpy) and the integration tests in the [tests directory](https://github.com/cpmech/plotpy/tree/main/tests)

Some output of integration tests are shown below.

## Contents <!-- omit from toc -->

- [Barplot](#barplot)
- [Boxplot](#boxplot)
- [Canvas](#canvas)
- [Contour](#contour)
- [Curve](#curve)
- [Histogram](#histogram)
- [Image](#image)
- [InsetAxes](#insetaxes)
- [Legend](#legend)
- [Plot](#plot)
- [Subplot and GridSpec](#subplot-and-gridspec)
- [Slope icon](#slope-icon)
- [Surface and wireframe](#surface-and-wireframe)
- [Text](#text)

## Barplot

[test_barplot.rs](https://github.com/cpmech/plotpy/tree/main/tests/test_barplot.rs)
Expand Down Expand Up @@ -81,6 +98,18 @@ Some output of integration tests are shown below.

![image](https://raw.githubusercontent.com/cpmech/plotpy/main/figures/integ_image_1.svg)

## InsetAxes

[test_inset_axes.rs](https://github.com/cpmech/plotpy/tree/main/tests/test_inset_axes.rs)

![inset_axes](https://raw.githubusercontent.com/cpmech/plotpy/main/figures/integ_inset_axes_1.svg)
![inset_axes](https://raw.githubusercontent.com/cpmech/plotpy/main/figures/integ_inset_axes_2.svg)
![inset_axes](https://raw.githubusercontent.com/cpmech/plotpy/main/figures/integ_inset_axes_3.svg)
![inset_axes](https://raw.githubusercontent.com/cpmech/plotpy/main/figures/integ_inset_axes_4.svg)
![inset_axes](https://raw.githubusercontent.com/cpmech/plotpy/main/figures/integ_inset_axes_5.svg)
![inset_axes](https://raw.githubusercontent.com/cpmech/plotpy/main/figures/integ_inset_axes_6.svg)


## Legend

[test_legend.rs](https://github.com/cpmech/plotpy/tree/main/tests/test_legend.rs)
Expand Down
Loading