Skip to content

Commit

Permalink
Merge pull request #18 from alceal:update-documentation
Browse files Browse the repository at this point in the history
doc: Update documentation examples
  • Loading branch information
alceal authored Sep 16, 2024
2 parents 2465c42 + 39add08 commit 3361d7d
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 120 deletions.
51 changes: 11 additions & 40 deletions src/traces/barplot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,31 @@ impl BarPlot {
/// * `plot_title` - An optional `Text` struct specifying the title of the plot.
/// * `x_title` - An optional `Text` struct specifying the title of the x-axis.
/// * `y_title` - An optional `Text` struct specifying the title of the y-axis.
/// * `legend_title` - An optional `Text` struct specifying the title of the legend.
/// * `x_axis` - An optional reference to an `Axis` struct for customizing the x-axis.
/// * `y_axis` - An optional reference to an `Axis` struct for customizing the y-axis.
/// * `legend_title` - An optional `Text` struct specifying the title of the legend.
/// * `legend` - An optional reference to a `Legend` struct for customizing the legend of the plot (e.g., positioning, font, etc.).
///
/// # Returns
///
/// Returns an instance of `BarPlot`.
///
/// **Examples**
/// **Example**
///
/// ```
/// let legend = Legend::new()
/// .orientation(Orientation::Horizontal)
/// .y(1.0)
/// .x(0.4);
///
/// BarPlot::builder()
/// .data(&dataset)
/// .data(&barplot_dataset)
/// .labels("animals")
/// .values("values")
/// .orientation(Orientation::Vertical)
/// .group("gender")
/// .error("errors")
/// .color(Rgb(255, 0, 0))
/// .colors(vec![Rgb(255, 127, 80), Rgb(64, 224, 208)])
/// .plot_title(
/// Text::from("Vertical Bar Plot")
/// .font("Arial")
Expand All @@ -86,46 +91,12 @@ impl BarPlot {
/// .font("Arial")
/// .size(15)
/// )
/// .legend(&legend)
/// .build()
/// .plot();
/// ```
///
/// ![Vertical Bar Plot](https://imgur.com/Fd6DpB0.png)
///
/// ```
/// BarPlot::builder()
/// .data(&dataset)
/// .labels("animals")
/// .values("values")
/// .orientation(Orientation::Horizontal)
/// .group("gender")
/// .error("errors")
/// .colors(vec![Rgb(255, 0, 0), Rgb(0, 255, 0)])
/// .plot_title(
/// Text::from("Horizontal Bar Plot")
/// .font("Arial")
/// .size(18)
/// )
/// .x_title(
/// Text::from("value")
/// .font("Arial")
/// .size(15)
/// )
/// .y_title(
/// Text::from("animal")
/// .font("Arial")
/// .size(15)
/// )
/// .legend_title(
/// Text::from("gender")
/// .font("Arial")
/// .size(15)
/// )
/// .build()
/// .plot();
/// ```
///
/// ![Horizontal Bar Plot](https://imgur.com/saoTcNg.png)
/// ![Bar Plot](https://imgur.com/2alZlO5.png)
#[builder(on(String, into), on(Text, into))]
pub fn new(
data: &DataFrame,
Expand Down
67 changes: 17 additions & 50 deletions src/traces/boxplot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,27 @@ impl BoxPlot {
/// * `plot_title` - An optional `Text` struct specifying the title of the plot.
/// * `x_title` - An optional `Text` struct specifying the title of the x-axis.
/// * `y_title` - An optional `Text` struct specifying the title of the y-axis.
/// * `legend_title` - An optional `Text` struct specifying the title of the legend.
/// * `x_axis` - An optional reference to an `Axis` struct for customizing the x-axis.
/// * `y_axis` - An optional reference to an `Axis` struct for customizing the y-axis.
/// * `legend_title` - An optional `Text` struct specifying the title of the legend.
/// * `legend` - An optional reference to a `Legend` struct for customizing the legend of the plot (e.g., positioning, font, etc.).
///
/// # Returns
///
/// Returns an instance of `BoxPlot`.
///
/// **Examples**
/// **Example**
///
/// ```
/// let axis_format = Axis::new()
/// .value_thousands(true);
///
/// let legend_format = Legend::new()
/// .border_width(1)
/// .x(0.9);
///
/// BoxPlot::builder()
/// .data(&dataset)
/// .data(&scatterplot_dataset)
/// .labels("species")
/// .values("body_mass_g")
/// .orientation(Orientation::Vertical)
Expand All @@ -72,12 +79,12 @@ impl BoxPlot {
/// .jitter(0.01)
/// .opacity(0.1)
/// .colors(vec![
/// Rgb(255, 0, 0),
/// Rgb(0, 255, 0),
/// Rgb(0, 0, 255),
/// Rgb(0, 191, 255),
/// Rgb(57, 255, 20),
/// Rgb(255, 105, 180),
/// ])
/// .plot_title(
/// Text::from("Vertical Box Plot")
/// Text::from("Box Plot")
/// .font("Arial")
/// .size(18)
/// )
Expand All @@ -91,58 +98,18 @@ impl BoxPlot {
/// .font("Arial")
/// .size(15)
/// )
/// .y_axis(&axis_format)
/// .legend_title(
/// Text::from("gender")
/// .font("Arial")
/// .size(15)
/// )
/// .legend(&legend_format)
/// .build()
/// .plot();
/// ```
///
/// ![Vertical Box Plot](https://imgur.com/0Zn0mFu.png)
///
/// ```
/// BoxPlot::builder()
/// .data(&dataset)
/// .labels("species")
/// .values("body_mass_g")
/// .orientation(Orientation::Horizontal)
/// .group("gender")
/// .box_points(true)
/// .point_offset(-1.5)
/// .jitter(0.01)
/// .opacity(0.1)
/// .colors(vec![
/// Rgb(255, 0, 0),
/// Rgb(0, 255, 0),
/// Rgb(0, 0, 255),
/// ])
/// .plot_title(
/// Text::from("Horizontal Box Plot")
/// .font("Arial")
/// .size(18)
/// )
/// .x_title(
/// Text::from("body mass (g)")
/// .font("Arial")
/// .size(15)
/// )
/// .y_title(
/// Text::from("species")
/// .font("Arial")
/// .size(15)
/// )
/// .legend_title(
/// Text::from("gender")
/// .font("Arial")
/// .size(15)
/// )
/// .build()
/// .plot();
/// ```
///
/// ![Horizontal Box Plot](https://imgur.com/Lu92liU.png)
/// ![Box Plot](https://imgur.com/uj1LY90.png)
#[builder(on(String, into), on(Text, into))]
pub fn new(
data: &DataFrame,
Expand Down
24 changes: 18 additions & 6 deletions src/traces/histogram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ impl Histogram {
/// * `plot_title` - An optional `Text` struct specifying the title of the plot.
/// * `x_title` - An optional `Text` struct specifying the title of the x-axis.
/// * `y_title` - An optional `Text` struct specifying the title of the y-axis.
/// * `legend_title` - An optional `Text` struct specifying the title of the legend.
/// * `x_axis` - An optional reference to an `Axis` struct for customizing the x-axis.
/// * `y_axis` - An optional reference to an `Axis` struct for customizing the y-axis.
/// * `legend_title` - An optional `Text` struct specifying the title of the legend.
/// * `legend` - An optional reference to a `Legend` struct for customizing the legend of the plot (e.g., positioning, font, etc.).
///
/// # Returns
Expand All @@ -50,15 +50,24 @@ impl Histogram {
/// **Example**
///
/// ```
/// let axis_format = Axis::new()
/// .show_line(true)
/// .show_grid(true)
/// .value_thousands(true)
/// .tick_direction(TickDirection::OutSide);
///
/// let legend_format = Legend::new()
/// .x(0.9);
///
/// Histogram::builder()
/// .data(&dataset)
/// .data(&scatterplot_dataset)
/// .x("body_mass_g")
/// .group("species")
/// .opacity(0.5)
/// .colors(vec![
/// Rgb(255, 0, 0),
/// Rgb(0, 255, 0),
/// Rgb(0, 0, 255),
/// Rgb(255, 165, 0),
/// Rgb(147, 112, 219),
/// Rgb(46, 139, 87),
/// ])
/// .plot_title(
/// Text::from("Histogram")
Expand All @@ -70,21 +79,24 @@ impl Histogram {
/// .font("Arial")
/// .size(15)
/// )
/// .x_axis(&axis_format)
/// .y_title(
/// Text::from("count")
/// .font("Arial")
/// .size(15)
/// )
/// .y_axis(&axis_format)
/// .legend_title(
/// Text::from("species")
/// .font("Arial")
/// .size(15)
/// )
/// .legend(&legend_format)
/// .build()
/// .plot();
/// ```
///
/// ![Histogram](https://imgur.com/ZNomy9V.png)
/// ![Histogram](https://imgur.com/w2oiuIo.png)
#[builder(on(String, into), on(Text, into))]
pub fn new(
data: &DataFrame,
Expand Down
33 changes: 21 additions & 12 deletions src/traces/lineplot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ impl LinePlot {
/// * `plot_title` - An optional `Text` struct specifying the title of the plot.
/// * `x_title` - An optional `Text` struct specifying the title of the x-axis.
/// * `y_title` - An optional `Text` struct specifying the title of the y-axis.
/// * `legend_title` - An optional `Text` struct specifying the title of the legend.
/// * `x_axis` - An optional reference to an `Axis` struct for customizing the x-axis.
/// * `y_axis` - An optional reference to an `Axis` struct for customizing the y-axis.
/// * `legend_title` - An optional `Text` struct specifying the title of the legend.
/// * `legend` - An optional reference to a `Legend` struct for customizing the legend of the plot (e.g., positioning, font, etc.).
///
/// # Returns
Expand All @@ -60,28 +60,37 @@ impl LinePlot {
///
/// ```
/// LinePlot::builder()
/// .data(&dataset)
/// .data(&lineplot_dataset)
/// .x("x")
/// .y("sine")
/// .additional_lines(vec!["cosine"])
/// .colors(vec![Rgb(255, 0, 0), Rgb(0, 255, 0)])
/// .line_types(vec![LineType::Solid, LineType::Dot])
/// .line_width(5.0)
/// .line_width(3.0)
/// .with_shape(false)
/// .plot_title(
/// Text::from("Line Plot")
/// .font("Arial")
/// .size(18)
/// )
/// .x_title(
/// Text::from("x")
/// .font("Arial")
/// .size(15)
/// .x_axis(
/// &Axis::new()
/// .tick_direction(TickDirection::OutSide)
/// .axis_position(0.5)
/// .tick_values(vec![
/// 0.5 * std::f64::consts::PI,
/// std::f64::consts::PI,
/// 1.5 * std::f64::consts::PI,
/// 2.0 * std::f64::consts::PI,
/// ])
/// .tick_labels(vec!["π/2", "π", "3π/2", "2π"])
/// )
/// .y_title(
/// Text::from("y")
/// .font("Arial")
/// .size(15)
/// .y_axis(
/// &Axis::new()
/// .tick_direction(TickDirection::OutSide)
/// .clone()
/// .tick_values(vec![-1.0, 0.0, 1.0])
/// .tick_labels(vec!["-1", "0", "1"])
/// )
/// .legend_title(
/// Text::from("series")
Expand All @@ -92,7 +101,7 @@ impl LinePlot {
/// .plot();
/// ```
///
/// ![Line Plot](https://imgur.com/0mqVyqX.png)
/// ![Line Plot](https://imgur.com/PaXG300.png)
#[builder(on(String, into), on(Text, into))]
pub fn new(
// Data
Expand Down
23 changes: 14 additions & 9 deletions src/traces/scatterplot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ impl ScatterPlot {
/// * `plot_title` - An optional `Text` struct specifying the title of the plot.
/// * `x_title` - An optional `Text` struct specifying the title of the x-axis.
/// * `y_title` - An optional `Text` struct specifying the title of the y-axis.
/// * `legend_title` - An optional `Text` struct specifying the title of the legend.
/// * `x_axis` - An optional reference to an `Axis` struct for customizing the x-axis.
/// * `y_axis` - An optional reference to an `Axis` struct for customizing the y-axis.
/// * `legend_title` - An optional `Text` struct specifying the title of the legend.
/// * `legend` - An optional reference to a `Legend` struct for customizing the legend of the plot (e.g., positioning, font, etc.).
///
/// # Returns
Expand All @@ -58,34 +58,39 @@ impl ScatterPlot {
/// .value_thousands(true);
///
/// ScatterPlot::builder()
/// .data(&dataset)
/// .data(&scatterplot_dataset)
/// .x("body_mass_g")
/// .y("flipper_length_mm")
/// .group("species")
/// .opacity(0.5)
/// .size(12)
/// .colors(vec![
/// Rgb(255, 0, 0),
/// Rgb(0, 255, 0),
/// Rgb(0, 0, 255),
/// Rgb(178, 34, 34),
/// Rgb(65, 105, 225),
/// Rgb(255, 140, 0),
/// ])
/// .shapes(vec![Shape::Circle, Shape::Square, Shape::Diamond])
/// .plot_title(
/// Text::from("Scatter Plot")
/// .font("Arial")
/// .size(20)
/// .x(0.045)
/// .x(0.065)
/// )
/// .x_title("body mass (g)")
/// .y_title("flipper length (mm)")
/// .legend_title("species")
/// .x_axis(&axis_format)
/// .y_axis(&axis_format)
/// .x_axis(&axis_format.clone().value_range(vec![2500.0, 6500.0]))
/// .y_axis(&axis_format.clone().value_range(vec![170.0, 240.0]))
/// .legend(
/// &Legend::new()
/// .x(0.85)
/// .y(0.15)
/// )
/// .build()
/// .plot();
/// ```
///
/// ![Scatter Plot](https://imgur.com/LQm4we9.png)
/// ![Scatter Plot](https://imgur.com/9jfO8RU.png)
#[builder(on(String, into), on(Text, into))]
pub fn new(
// Data
Expand Down
Loading

0 comments on commit 3361d7d

Please sign in to comment.