pub struct OhlcPlot { /* private fields */ }Expand description
A structure representing an OHLC (Open-High-Low-Close) financial chart.
The OhlcPlot struct facilitates the creation and customization of OHLC charts commonly used
for visualizing financial data such as stock prices. It supports multiple OHLC series, custom
styling for increasing/decreasing values, hover information, and comprehensive layout customization
including range selectors and sliders for interactive time navigation.
§Backend Support
| Backend | Supported |
|---|---|
| Plotly | Yes |
| Plotters | – |
§Arguments
data- A reference to theDataFramecontaining the data to be plotted.dates- A string slice specifying the column name for dates/timestamps.open- A string slice specifying the column name for opening values.high- A string slice specifying the column name for high values.low- A string slice specifying the column name for low values.close- A string slice specifying the column name for closing values.tick_width- An optionalf64specifying the width of the open/close ticks (0-1 range).plot_title- An optionalTextstruct specifying the title of the plot.x_title- An optionalTextstruct specifying the title of the x-axis.y_title- An optionalTextstruct specifying the title of the y-axis.x_axis- An optional reference to anAxisstruct for customizing the x-axis.y_axis- An optional reference to anAxisstruct for customizing the y-axis.
§Examples
use plotlars::{Axis, OhlcPlot, Plot};
use polars::prelude::*;
let stock_data = LazyCsvReader::new(PlRefPath::new("data/stock_prices.csv"))
.finish()
.unwrap()
.collect()
.unwrap();
OhlcPlot::builder()
.data(&stock_data)
.dates("date")
.open("open")
.high("high")
.low("low")
.close("close")
.plot_title("OHLC Plot")
.y_title("Price ($)")
.y_axis(
&Axis::new()
.show_axis(true)
)
.build()
.plot();
Implementations§
Source§impl OhlcPlot
impl OhlcPlot
pub fn builder<'f1, 'f2, 'f3, 'f4, 'f5, 'f6, 'f7, 'f8>() -> OhlcPlotBuilder<'f1, 'f2, 'f3, 'f4, 'f5, 'f6, 'f7, 'f8>
Source§impl OhlcPlot
impl OhlcPlot
pub fn try_new( data: &DataFrame, dates: &str, open: &str, high: &str, low: &str, close: &str, tick_width: Option<f64>, plot_title: Option<Text>, x_title: Option<Text>, y_title: Option<Text>, x_axis: Option<&Axis>, y_axis: Option<&Axis>, ) -> Result<Self, PlotlarsError>
pub fn try_builder<'f1, 'f2, 'f3, 'f4, 'f5, 'f6, 'f7, 'f8>() -> OhlcPlotTryBuilder<'f1, 'f2, 'f3, 'f4, 'f5, 'f6, 'f7, 'f8>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for OhlcPlot
impl RefUnwindSafe for OhlcPlot
impl Send for OhlcPlot
impl Sync for OhlcPlot
impl Unpin for OhlcPlot
impl UnsafeUnpin for OhlcPlot
impl UnwindSafe for OhlcPlot
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