Skip to content

Commit 251c12f

Browse files
authored
Merge branch 'main' into main
2 parents c52b692 + 1fb44cf commit 251c12f

File tree

4 files changed

+69
-186
lines changed

4 files changed

+69
-186
lines changed

.github/workflows/rust.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Rust
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Build
20+
run: cargo build --verbose
21+
# - name: Run tests
22+
# run: cargo test --verbose
23+
- name: Format
24+
run: cargo fmt
25+
- name: Clippy
26+
run: cargo clippy

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,4 @@ target/
7272
notebook
7373

7474
**/main*.rs
75+
.markdownlint.json

README.md

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,34 @@
11
# Plotlars
22

33
<p align="center">
4-
<a href="https://crates.io/crates/plotlars"><img alt="Crates.io" src="https://img.shields.io/crates/v/plotlars.svg"></a>
5-
<a href="https://docs.rs/plotlars"><img alt="docs.rs" src="https://img.shields.io/docsrs/plotlars"></a>
6-
<a href="https://github.com/your-repo/plotlars/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/badge/license-MIT-blue.svg"></a>
4+
<a href="https://crates.io/crates/plotlars">
5+
<img alt="Crates.io" src="https://img.shields.io/crates/v/plotlars.svg"></a>
6+
<a href="https://docs.rs/plotlars">
7+
<img alt="docs.rs" src="https://img.shields.io/docsrs/plotlars">
8+
</a>
9+
<a href="https://github.com/your-repo/plotlars/blob/main/LICENSE">
10+
<img alt="License" src="https://img.shields.io/badge/license-MIT-blue.svg">
11+
</a>
712
</p>
813

9-
10-
Plotlars is a versatile Rust library that acts as a wrapper around the Plotly crate, bridging the gap between the powerful Polars data analysis library and Plotly. It simplifies the process of creating visualizations from data frames, allowing developers to focus on data insights rather than the intricacies of plot creation.
14+
Plotlars is a versatile Rust library that acts as a wrapper around the Plotly
15+
crate, bridging the gap between the powerful Polars data analysis library and
16+
Plotly. It simplifies the process of creating visualizations from data frames,
17+
allowing developers to focus on data insights rather than the intricacies of
18+
plot creation.
1119

1220
## Motivation
1321

14-
The creation of Plotlars was driven by the need to simplify the process of creating complex plots in Rust, particularly when working with the powerful Polars data manipulation library. Generating visualizations often requires extensive boilerplate code and deep knowledge of both the plotting library (Plotly) and the data structure. This complexity can be a significant hurdle, especially for users who need to focus on analyzing and interpreting data rather than wrestling with intricate plotting logic.
15-
16-
To illustrate this, consider the following example where a scatter plot is created without Plotlars:
22+
The creation of Plotlars was driven by the need to simplify the process of
23+
creating complex plots in Rust, particularly when working with the powerful
24+
Polars data manipulation library. Generating visualizations often requires
25+
extensive boilerplate code and deep knowledge of both the plotting library
26+
(Plotly) and the data structure. This complexity can be a significant hurdle,
27+
especially for users who need to focus on analyzing and interpreting data rather
28+
than wrestling with intricate plotting logic.
1729

18-
**Without Plotlars**
30+
To illustrate this, consider the following example where a scatter plot is
31+
created **without Plotlars**:
1932

2033
```rust
2134
use plotly::{
@@ -92,11 +105,11 @@ fn main() {
92105
}
93106
```
94107

95-
In this example, creating a scatter plot involves writing substantial code to manually handle the data and configure the plot, including grouping the data by category and setting up the plot layout.
96-
97-
**With Plotlars**
108+
In this example, creating a scatter plot involves writing substantial code to
109+
manually handle the data and configure the plot, including grouping the data by
110+
category and setting up the plot layout.
98111

99-
Now, compare that to the same plot created using Plotlars:
112+
Now, compare that to the same plot created **using Plotlars**:
100113

101114
```rust
102115
use plotlars::{
@@ -142,7 +155,11 @@ This is the output:
142155

143156
![Plot example](https://imgur.com/PkQ9fsc.png)
144157

145-
With Plotlars, the same scatter plot is created with significantly less code. The library abstracts away the complexities of dealing with individual plot components and allows the user to specify high-level plot characteristics. This streamlined approach not only saves time but also reduces the potential for errors and makes the code more readable and maintainable.
158+
With Plotlars, the same scatter plot is created with significantly less code.
159+
The library abstracts away the complexities of dealing with individual plot
160+
components and allows the user to specify high-level plot characteristics. This
161+
streamlined approach not only saves time but also reduces the potential for
162+
errors and makes the code more readable and maintainable.
146163

147164
## Installation
148165

@@ -152,8 +169,10 @@ cargo add plotlars
152169

153170
## Features
154171

155-
- Seamless Integration with Polars: Leverage the power of Polars for efficient data manipulation and analysis.
156-
- Support for Multiple Plot Types: Easily create bar, line, scatter, and other plot types.
172+
- Seamless Integration with Polars: Leverage the power of Polars for efficient
173+
data manipulation and analysis.
174+
- Support for Multiple Plot Types: Easily create bar, line, scatter, and other
175+
plot types.
157176
- Customization: Modify plot appearance with an intuitive API.
158177

159178
## License
@@ -162,6 +181,9 @@ This project is licensed under the MIT License. See the LICENSE.txt file for det
162181

163182
## Acknowledgements
164183

165-
- [Polars](https://github.com/pola-rs/polars): For providing a fast and efficient data manipulation library.
166-
- [Plotly](https://github.com/plotly/plotly.rs): For the inspiration and ideas behind visualization libraries.
167-
- Rust Community: For the support and development of an amazing programming language.
184+
- [Polars](https://github.com/pola-rs/polars): For providing a fast and
185+
efficient data manipulation library.
186+
- [Plotly](https://github.com/plotly/plotly.rs): For the inspiration and ideas
187+
behind visualization libraries.
188+
- Rust Community: For the support and development of an amazing programming
189+
language.

src/lib.rs

Lines changed: 1 addition & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -1,171 +1,5 @@
1+
#![doc = include_str!("../README.md")]
12
#![allow(clippy::needless_doctest_main)]
2-
//! # Plotlars
3-
//!
4-
//! <p align="center">
5-
//! <a href="https://crates.io/crates/plotlars"><img alt="Crates.io" src="https://img.shields.io/crates/v/plotlars.svg"></a>
6-
//! <a href="https://docs.rs/plotlars"><img alt="docs.rs" src="https://img.shields.io/docsrs/plotlars"></a>
7-
//! <a href="https://github.com/your-repo/plotlars/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/badge/license-MIT-blue.svg"></a>
8-
//! </p>
9-
//!
10-
//!
11-
//! Plotlars is a versatile Rust library that bridges the gap between the powerful Polars data analysis library and Plotly library. It simplifies the process of creating visualizations from data frames, allowing developers to focus on data insights rather than the intricacies of plot creation.
12-
//!
13-
//! ## Motivation
14-
//!
15-
//! The creation of Plotlars was driven by the need to simplify the process of creating complex plots in Rust, particularly when working with the powerful Polars data manipulation library. Generating visualizations often requires extensive boilerplate code and deep knowledge of both the plotting library and the data structure. This complexity can be a significant hurdle, especially for users who need to focus on analyzing and interpreting data rather than wrestling with intricate plotting logic.
16-
//!
17-
//! To illustrate this, consider the following example where a scatter plot is created without Plotlars:
18-
//!
19-
//! **Without Plotlars**
20-
//!
21-
//! ```rust
22-
//! use plotly::{
23-
//! common::*,
24-
//! layout::*,
25-
//! Plot,
26-
//! Scatter,
27-
//! };
28-
//!
29-
//! use polars::prelude::*;
30-
//!
31-
//! fn main() {
32-
//! let dataset = LazyCsvReader::new("data/penguins.csv")
33-
//! .finish().unwrap()
34-
//! .select([
35-
//! col("species").cast(
36-
//! DataType::Categorical(
37-
//! None,
38-
//! CategoricalOrdering::default()
39-
//! )
40-
//! ),
41-
//! col("flipper_length_mm").cast(DataType::Int16),
42-
//! col("body_mass_g").cast(DataType::Int16),
43-
//! ])
44-
//! .collect().unwrap();
45-
//!
46-
//! let group_column = "species";
47-
//! let x = "body_mass_g";
48-
//! let y = "flipper_length_mm";
49-
//!
50-
//! let groups = dataset
51-
//! .column(group_column).unwrap()
52-
//! .unique().unwrap();
53-
//!
54-
//! let layout = Layout::new()
55-
//! .title(Title::with_text("Penguin Flipper Length vs Body Mass"))
56-
//! .x_axis(Axis::new().title(Title::with_text("Body Mass (g)")))
57-
//! .y_axis(Axis::new().title(Title::with_text("Flipper Length (mm)")))
58-
//! .legend(Legend::new().title(Title::with_text("Species")));
59-
//!
60-
//! let mut plot = Plot::new();
61-
//! plot.set_layout(layout);
62-
//!
63-
//! for group in groups.iter() {
64-
//! let group = group.get_str().unwrap();
65-
//!
66-
//! let data = dataset
67-
//! .clone()
68-
//! .lazy()
69-
//! .filter(col(group_column).eq(lit(group)))
70-
//! .collect().unwrap();
71-
//!
72-
//! let x = data
73-
//! .column(x).unwrap()
74-
//! .i16().unwrap()
75-
//! .to_vec();
76-
//!
77-
//! let y = data
78-
//! .column(y).unwrap()
79-
//! .i16().unwrap()
80-
//! .to_vec();
81-
//!
82-
//! let trace = Scatter::default()
83-
//! .x(x)
84-
//! .y(y)
85-
//! .name(group)
86-
//! .mode(Mode::Markers)
87-
//! .marker(Marker::new().size(10).opacity(0.5));
88-
//!
89-
//! plot.add_trace(trace);
90-
//! }
91-
//!
92-
//! plot.show();
93-
//! }
94-
//! ```
95-
//!
96-
//! In this example, creating a scatter plot involves writing substantial code to manually handle the data and configure the plot, including grouping the data by category and setting up the plot layout.
97-
//!
98-
//! **With Plotlars**
99-
//!
100-
//! Now, compare that to the same plot created using Plotlars:
101-
//!
102-
//! ```rust
103-
//! use plotlars::{
104-
//! ScatterPlot,
105-
//! Plot,
106-
//! Text,
107-
//! };
108-
//!
109-
//! use polars::prelude::*;
110-
//!
111-
//! fn main() {
112-
//! let dataset = LazyCsvReader::new("data/penguins.csv")
113-
//! .finish().unwrap()
114-
//! .select([
115-
//! col("species").cast(
116-
//! DataType::Categorical(
117-
//! None,
118-
//! CategoricalOrdering::default()
119-
//! )
120-
//! ),
121-
//! col("flipper_length_mm").cast(DataType::Int16),
122-
//! col("body_mass_g").cast(DataType::Int16),
123-
//! ])
124-
//! .collect().unwrap();
125-
//!
126-
//! ScatterPlot::builder()
127-
//! .data(&dataset)
128-
//! .x("body_mass_g")
129-
//! .y("flipper_length_mm")
130-
//! .group("species")
131-
//! .size(10)
132-
//! .opacity(0.5)
133-
//! .plot_title(Text::from("Penguin Flipper Length vs Body Mass"))
134-
//! .x_title(Text::from("Body Mass (g)"))
135-
//! .y_title(Text::from("Flipper Length (mm)"))
136-
//! .legend_title(Text::from("Species"))
137-
//! .build()
138-
//! .plot();
139-
//! }
140-
//! ```
141-
//!
142-
//! This is the output:
143-
//!
144-
//! ![Plot example](https://imgur.com/PkQ9fsc.png)
145-
//!
146-
//! With Plotlars, the same scatter plot is created with significantly less code. The library abstracts away the complexities of dealing with individual plot components and allows the user to specify high-level plot characteristics. This streamlined approach not only saves time but also reduces the potential for errors and makes the code more readable and maintainable.
147-
//!
148-
//! ## Installation
149-
//!
150-
//! ```bash
151-
//! cargo add plotlars
152-
//! ```
153-
//!
154-
//! ## Features
155-
//!
156-
//! - Seamless Integration with Polars: Leverage the power of Polars for efficient data manipulation and analysis.
157-
//! - Support for Multiple Plot Types: Easily create bar, line, scatter, and other plot types.
158-
//! - Customization: Modify plot appearance with an intuitive API.
159-
//!
160-
//! ## License
161-
//!
162-
//! This project is licensed under the MIT License. See the LICENSE.txt file for details.
163-
//!
164-
//! ## Acknowledgements
165-
//!
166-
//! - [Polars](https://github.com/pola-rs/polars): For providing a fast and efficient data manipulation library.
167-
//! - [Plotly](https://github.com/plotly/plotly.rs): For the inspiration and ideas behind visualization libraries.
168-
//! - Rust Community: For the support and development of an amazing programming language.
1693

1704
#[macro_use]
1715
mod macros;

0 commit comments

Comments
 (0)