Struct plotly::plot::Plot [−][src]
Plot is a container for structs that implement the Trace
trait. Optionally a Layout
can
also be specified. Its function is to serialize Trace
s and the Layout
in html format and
display and/or persist the resulting plot.
Examples
extern crate plotly; use plotly::common::Mode; use plotly::{Plot, Scatter}; fn line_and_scatter_plot() { let trace1 = Scatter::new(vec![1, 2, 3, 4], vec![10, 15, 13, 17]) .name("trace1") .mode(Mode::Markers); let trace2 = Scatter::new(vec![2, 3, 4, 5], vec![16, 5, 11, 9]) .name("trace2") .mode(Mode::Lines); let trace3 = Scatter::new(vec![1, 2, 3, 4], vec![12, 9, 15, 12]).name("trace3"); let mut plot = Plot::new(); plot.add_trace(trace1); plot.add_trace(trace2); plot.add_trace(trace3); plot.show(); } fn main() -> std::io::Result<()> { line_and_scatter_plot(); Ok(()) }
Implementations
impl Plot
[src]
pub fn new() -> Plot
[src]
Create a new Plot
.
pub fn use_local_plotly(&mut self)
[src]
This option results in the plotly.js library being written directly in the html output. The benefit is that the plot will load faster in the browser and the downside is that the resulting html will be much larger.
pub fn add_trace(&mut self, trace: Box<dyn Trace>)
[src]
Add a Trace
to the Plot
.
pub fn add_traces(&mut self, traces: Vec<Box<dyn Trace>>)
[src]
Add multiple Trace
s to the Plot
.
pub fn set_layout(&mut self, layout: Layout)
[src]
Set the Layout
to be used by Plot
.
pub fn show(&self)
[src]
Renders the contents of the Plot
and displays them in the system default browser.
This will serialize the Trace
s and Layout
in an html page which is saved in the temp
directory. For example on Linux it will generate a file plotly_<22 random characters>.html
in the /tmp directory.
pub fn show_png(&self, width: usize, height: usize)
[src]
Renders the contents of the Plot
, creates a png raster and displays it in the system default browser.
To save the resulting png right-click on the resulting image and select Save As...
.
pub fn show_jpeg(&self, width: usize, height: usize)
[src]
Renders the contents of the Plot
, creates a jpeg raster and displays it in the system default browser.
To save the resulting png right-click on the resulting image and select Save As...
.
pub fn to_html<P: AsRef<Path>>(&self, filename: P)
[src]
Renders the contents of the Plot
and displays it in the system default browser.
In contrast to Plot::show()
this will save the resulting html in a user specified location
instead of the system temp directory.
pub fn to_inline_html<T: Into<Option<&'static str>>>(
&self,
plot_div_id: T
) -> String
[src]
&self,
plot_div_id: T
) -> String
Renders the contents of the Plot
and returns it as a String, for embedding in
web-pages or Jupyter notebooks. A div
is generated with the supplied id followed by the
script that generates the plot. The assumption is that plotly.js is available within the
html page that this element is embedded. If that assumption is violated then the plot will
not be displayed.
If plot_div_id
is None
the plot div id will be randomly generated, otherwise the user
supplied div id is used.
pub fn notebook_display(&self)
[src]
Display plot in Jupyter Notebook.
pub fn lab_display(&self)
[src]
Display plot in Jupyter Lab.
pub fn evcxr_display(&self)
[src]
Displays the plot in Jupyter Lab; if running a Jupyter Notebook then use the
notebook_display()
method instead.
pub fn to_json(&self) -> String
[src]
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Plot
[src]
impl !Send for Plot
[src]
impl !Sync for Plot
[src]
impl Unpin for Plot
[src]
impl !UnwindSafe for Plot
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src]
V: MultiLane<T>,