pub struct ScatterMap { /* private fields */ }Expand description
A structure representing a scatter plot on a map.
The ScatterMap struct allows for visualizing geographical data points on an interactive map.
Each data point is defined by its latitude and longitude, with additional options for grouping,
coloring, size, opacity, and map configuration such as zoom level and center coordinates.
This struct is ideal for displaying spatial data distributions, such as city locations or geospatial datasets.
§Arguments
data- A reference to theDataFramecontaining the data to be plotted.latitude- A string slice specifying the column name containing latitude values.longitude- A string slice specifying the column name containing longitude values.center- An optional array[f64; 2]specifying the initial center point of the map ([latitude, longitude]).zoom- An optionalu8specifying the initial zoom level of the map.group- An optional string slice specifying the column name for grouping data points (e.g., by city or category).sort_groups_by- Optional comparatorfn(&str, &str) -> std::cmp::Orderingto control group ordering. Groups are sorted lexically by default.opacity- An optionalf64value between0.0and1.0specifying the opacity of the points.size- An optionalusizespecifying the size of the scatter points.color- An optionalRgbvalue specifying the color of the points (if no grouping is applied).colors- An optional vector ofRgbvalues specifying colors for grouped points.shape- An optionalShapeenum specifying the marker shape for the points.shapes- An optional vector ofShapeenums specifying shapes for grouped points.plot_title- An optionalTextstruct specifying the title of the plot.legend_title- An optionalTextstruct specifying the title of the legend.legend- An optional reference to aLegendstruct for customizing the legend (e.g., positioning, font, etc.).
§Example
§Basic Scatter Map Plot
use polars::prelude::*;
use plotlars::{Plot, ScatterMap, Text};
let dataset = LazyCsvReader::new(PlPath::new("data/cities.csv"))
.finish()
.unwrap()
.collect()
.unwrap();
ScatterMap::builder()
.data(&dataset)
.latitude("latitude")
.longitude("longitude")
.center([48.856613, 2.352222])
.zoom(4)
.group("city")
.opacity(0.5)
.size(12)
.plot_title(
Text::from("Scatter Map")
.font("Arial")
.size(18)
)
.legend_title("cities")
.build()
.plot();
Implementations§
Source§impl ScatterMap
impl ScatterMap
Sourcepub fn builder<'f1, 'f2, 'f3, 'f4, 'f5>() -> ScatterMapBuilder<'f1, 'f2, 'f3, 'f4, 'f5>
pub fn builder<'f1, 'f2, 'f3, 'f4, 'f5>() -> ScatterMapBuilder<'f1, 'f2, 'f3, 'f4, 'f5>
Examples found in repository?
examples/scattermap.rs (line 12)
5fn main() {
6 let dataset = LazyCsvReader::new(PlPath::new("data/cities.csv"))
7 .finish()
8 .unwrap()
9 .collect()
10 .unwrap();
11
12 ScatterMap::builder()
13 .data(&dataset)
14 .latitude("latitude")
15 .longitude("longitude")
16 .center([48.856613, 2.352222])
17 .zoom(4)
18 .group("city")
19 .opacity(0.5)
20 .size(12)
21 .plot_title(Text::from("Scatter Map").font("Arial").size(18))
22 .legend_title("cities")
23 .build()
24 .plot();
25}Trait Implementations§
Source§impl Clone for ScatterMap
impl Clone for ScatterMap
Source§fn clone(&self) -> ScatterMap
fn clone(&self) -> ScatterMap
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl PlotHelper for ScatterMap
impl PlotHelper for ScatterMap
fn get_layout(&self) -> &LayoutPlotly
fn get_traces(&self) -> &Vec<Box<dyn Trace + 'static>>
Auto Trait Implementations§
impl Freeze for ScatterMap
impl !RefUnwindSafe for ScatterMap
impl !Send for ScatterMap
impl !Sync for ScatterMap
impl Unpin for ScatterMap
impl !UnwindSafe for ScatterMap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more