From c5c4ad43ff8d438d1e6cac17796ec2cca2696ab8 Mon Sep 17 00:00:00 2001 From: alceal Date: Sat, 4 Jan 2025 22:42:44 +0100 Subject: [PATCH] fix: Rename Array2DPlot to Array2dPlot for consistency --- src/lib.rs | 2 +- src/plots/array2dplot.rs | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b7ea560..1d8a407 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,7 +17,7 @@ pub use crate::components::palette::Palette; pub use crate::components::shape::Shape; pub use crate::components::text::Text; pub use crate::components::tick::TickDirection; -pub use crate::plots::array2dplot::Array2DPlot; +pub use crate::plots::array2dplot::Array2dPlot; pub use crate::plots::barplot::BarPlot; pub use crate::plots::boxplot::BoxPlot; pub use crate::plots::heatmap::HeatMap; diff --git a/src/plots/array2dplot.rs b/src/plots/array2dplot.rs index c7a4285..3a268fd 100644 --- a/src/plots/array2dplot.rs +++ b/src/plots/array2dplot.rs @@ -11,13 +11,13 @@ use crate::{ /// A structure representing a 2D array plot. /// -/// The `Array2DPlot` struct allows for visualizing 2D arrays of RGB color values as images or heatmaps. +/// The `Array2dPlot` struct allows for visualizing 2D arrays of RGB color values as images or heatmaps. /// Each element in the 2D array corresponds to a pixel, with its color defined by an `[u8; 3]` RGB triplet. /// This struct supports customizable titles, axis labels, and axis configurations for better presentation. /// /// # Arguments /// -/// * `data` - A 2D vector of RGB triplets (`Vec>`) representing pixel colors for the plot. +/// * `data` - A 2D vector of RGB triplets (`&[Vec<[u8; 3]>]`) representing pixel colors for the plot. /// * `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. @@ -29,7 +29,7 @@ use crate::{ /// ## Basic 2D Array Plot /// /// ```rust -/// use plotlars::{Array2DPlot, Plot, Text}; +/// use plotlars::{Array2dPlot, Plot, Text}; /// /// let data = vec![ /// vec![[255, 0, 0], [0, 255, 0], [0, 0, 255]], @@ -37,7 +37,7 @@ use crate::{ /// vec![[0, 255, 0], [0, 0, 255], [255, 0, 0]], /// ]; /// -/// Array2DPlot::builder() +/// Array2dPlot::builder() /// .data(&data) /// .plot_title( /// Text::from("Array2D Plot") @@ -50,13 +50,13 @@ use crate::{ /// /// ![Example](https://imgur.com/LMrqAaT.png) #[derive(Clone, Serialize)] -pub struct Array2DPlot { +pub struct Array2dPlot { traces: Vec>, layout: LayoutPlotly, } #[bon] -impl Array2DPlot { +impl Array2dPlot { #[builder(on(String, into), on(Text, into))] pub fn new( data: &[Vec<[u8; 3]>], @@ -97,7 +97,7 @@ impl Array2DPlot { .iter() .map(|row| { row.iter() - .map(|rgb| Rgb(rgb[0], rgb[1], rgb[2]).to_plotly()) + .map(|&rgb| Rgb(rgb[0], rgb[1], rgb[2]).to_plotly()) .collect::>() }) .collect::>(); @@ -106,9 +106,9 @@ impl Array2DPlot { } } -impl Layout for Array2DPlot {} +impl Layout for Array2dPlot {} -impl PlotHelper for Array2DPlot { +impl PlotHelper for Array2dPlot { fn get_layout(&self) -> &LayoutPlotly { &self.layout }