pub struct ScatterGeo { /* private fields */ }Expand description
A structure representing a geographic scatter plot.
The ScatterGeo struct facilitates the creation and customization of geographic scatter plots
with various options for data selection, grouping, layout configuration, and aesthetic adjustments.
It supports plotting data points on a map using latitude and longitude coordinates, with customization
for markers, lines, text labels, and comprehensive layout options.
§Backend Support
| Backend | Supported |
|---|---|
| Plotly | Yes |
| Plotters | – |
§Arguments
data- A reference to theDataFramecontaining the data to be plotted.lat- A string slice specifying the column name to be used for latitude coordinates.lon- A string slice specifying the column name to be used for longitude coordinates.mode- An optionalModespecifying the drawing mode (markers, lines, or both).text- An optional string slice specifying the column name to be used for text labels.group- An optional string slice specifying the column name to be used for grouping data points.sort_groups_by- Optional comparatorfn(&str, &str) -> std::cmp::Orderingto control group ordering. Groups are sorted lexically by default.opacity- An optionalf64value specifying the opacity of the plot elements (range: 0.0 to 1.0).size- An optionalusizespecifying the size of the markers.color- An optionalRgbvalue specifying the color of the markers. This is used whengroupis not specified.colors- An optional vector ofRgbvalues specifying the colors for the markers. This is used whengroupis specified.shape- An optionalShapespecifying the shape of the markers. This is used whengroupis not specified.shapes- An optional vector ofShapevalues specifying multiple shapes for the markers when plotting multiple groups.line_width- An optionalf64value specifying the width of the lines (when mode includes lines).line_color- An optionalRgbvalue specifying the color of the lines.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 of the plot.
§Example
use plotlars::{Plot, Rgb, ScatterGeo, Shape, Text, Mode};
use polars::prelude::*;
let data = LazyCsvReader::new(PlRefPath::new("data/us_cities_regions.csv"))
.finish()
.unwrap()
.collect()
.unwrap();
ScatterGeo::builder()
.data(&data)
.lat("lat")
.lon("lon")
.mode(Mode::Markers)
.text("city")
.group("region")
.size(15)
.colors(vec![
Rgb(255, 0, 0),
Rgb(0, 255, 0),
Rgb(0, 0, 255),
Rgb(255, 165, 0),
])
.plot_title(
Text::from("Scatter Geo Plot")
.font("Arial")
.size(24)
.x(0.5)
)
.legend_title(
Text::from("Region")
.size(14)
)
.build()
.plot();
Implementations§
Source§impl ScatterGeo
impl ScatterGeo
pub fn builder<'f1, 'f2, 'f3, 'f4, 'f5, 'f6>() -> ScatterGeoBuilder<'f1, 'f2, 'f3, 'f4, 'f5, 'f6>
Source§impl ScatterGeo
impl ScatterGeo
pub fn try_new( data: &DataFrame, lat: &str, lon: &str, mode: Option<Mode>, text: Option<&str>, group: Option<&str>, sort_groups_by: Option<fn(&str, &str) -> Ordering>, opacity: Option<f64>, size: Option<usize>, color: Option<Rgb>, colors: Option<Vec<Rgb>>, shape: Option<Shape>, shapes: Option<Vec<Shape>>, line_width: Option<f64>, line_color: Option<Rgb>, plot_title: Option<Text>, legend_title: Option<Text>, legend: Option<&Legend>, ) -> Result<Self, PlotlarsError>
pub fn try_builder<'f1, 'f2, 'f3, 'f4, 'f5, 'f6>() -> ScatterGeoTryBuilder<'f1, 'f2, 'f3, 'f4, 'f5, 'f6>
Trait Implementations§
Source§impl Clone for ScatterGeo
impl Clone for ScatterGeo
Source§fn clone(&self) -> ScatterGeo
fn clone(&self) -> ScatterGeo
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 moreAuto Trait Implementations§
impl Freeze for ScatterGeo
impl RefUnwindSafe for ScatterGeo
impl Send for ScatterGeo
impl Sync for ScatterGeo
impl Unpin for ScatterGeo
impl UnsafeUnpin for ScatterGeo
impl UnwindSafe for ScatterGeo
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