Struct plotly::traces::image::Image

source ·
pub struct Image { /* private fields */ }
Expand description

Construct an image trace.

Examples

use plotly::{color::Rgb, image::ColorModel, Image};

let b = Rgb::new(0, 0, 0);
let w = Rgb::new(255, 255, 255);

let z = vec![
    vec![b, w],
    vec![w, b],
];

let trace = Image::new(z).color_model(ColorModel::RGB);

let expected = serde_json::json!({
    "type": "image",
    "z": [[[0, 0, 0], [255, 255, 255]], [[255, 255, 255], [0, 0, 0]]],
    "colormodel": "rgb"
});

assert_eq!(serde_json::to_value(trace).unwrap(), expected);

Implementations§

source§

impl Image

source

pub fn name(self, value: impl AsRef<str>) -> Box<Self>

Sets the trace name. The trace name appear as the legend item and on hover.

source

pub fn modify_all_name(value: impl AsRef<str>) -> RestyleImage

Apply the same restyling to all the traces

source

pub fn modify_name(values: Vec<impl AsRef<str>>) -> RestyleImage

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn visible(self, value: Visible) -> Box<Self>

Determines whether or not this trace is visible. If Visible::LegendOnly, the trace is not drawn, but can appear as a legend item (provided that the legend itself is visible).

source

pub fn modify_all_visible(value: Visible) -> RestyleImage

Apply the same restyling to all the traces

source

pub fn modify_visible(values: Vec<Visible>) -> RestyleImage

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn legend_rank(self, value: usize) -> Box<Self>

Sets the legend rank for this trace. Items and groups with smaller ranks are presented on top/left side while with "reversed" legend.trace_order` they are on bottom/right side. The default legendrank is 1000, so that you can use ranks less than 1000 to place certain items before all unranked items, and ranks greater than 1000 to go after all unranked items.

source

pub fn modify_all_legend_rank(value: usize) -> RestyleImage

Apply the same restyling to all the traces

source

pub fn modify_legend_rank(values: Vec<usize>) -> RestyleImage

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn legend_group_title(self, value: LegendGroupTitle) -> Box<Self>

Set and style the title to appear for the legend group.

source

pub fn modify_all_legend_group_title(value: LegendGroupTitle) -> RestyleImage

Apply the same restyling to all the traces

source

pub fn modify_legend_group_title(values: Vec<LegendGroupTitle>) -> RestyleImage

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn opacity(self, value: f64) -> Box<Self>

Sets the opacity of the trace.

source

pub fn modify_all_opacity(value: f64) -> RestyleImage

Apply the same restyling to all the traces

source

pub fn modify_opacity(values: Vec<f64>) -> RestyleImage

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn ids(self, value: Vec<impl AsRef<str>>) -> Box<Self>

Assigns id labels to each datum. These ids for object constancy of data points during animation. Should be an array of strings, not numbers or any other type.

source

pub fn modify_all_ids(value: Vec<impl AsRef<str>>) -> RestyleImage

Apply the same restyling to all the traces

source

pub fn modify_ids(values: Vec<Vec<impl AsRef<str>>>) -> RestyleImage

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn x0(self, value: impl Into<NumOrString>) -> Box<Self>

Set the image’s x position.

source

pub fn modify_all_x0(value: impl Into<NumOrString>) -> RestyleImage

Apply the same restyling to all the traces

source

pub fn modify_x0(values: Vec<impl Into<NumOrString>>) -> RestyleImage

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn dx(self, value: f64) -> Box<Self>

Set the pixel’s horizontal size.

source

pub fn modify_all_dx(value: f64) -> RestyleImage

Apply the same restyling to all the traces

source

pub fn modify_dx(values: Vec<f64>) -> RestyleImage

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn y0(self, value: impl Into<NumOrString>) -> Box<Self>

Set the image’s y position.

source

pub fn modify_all_y0(value: impl Into<NumOrString>) -> RestyleImage

Apply the same restyling to all the traces

source

pub fn modify_y0(values: Vec<impl Into<NumOrString>>) -> RestyleImage

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn dy(self, value: f64) -> Box<Self>

Set the pixel’s vertical size.

source

pub fn modify_all_dy(value: f64) -> RestyleImage

Apply the same restyling to all the traces

source

pub fn modify_dy(values: Vec<f64>) -> RestyleImage

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn source(self, value: impl AsRef<str>) -> Box<Self>

Specifies the data URI of the image to be visualized. The URI consists of “data:image/[][;base64],”.

source

pub fn modify_all_source(value: impl AsRef<str>) -> RestyleImage

Apply the same restyling to all the traces

source

pub fn modify_source(values: Vec<impl AsRef<str>>) -> RestyleImage

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn text(self, value: impl AsRef<str>) -> Box<Self>

Sets text elements associated with each (x,y) pair. If a single string, the same string appears over all the data points. If an array of strings the items are mapped in order to the this trace’s (x,y) coordinates. If the trace HoverInfo contains a “text” flag and hover_text is not set, these elements will be seen in the hover labels.

source

pub fn modify_all_text(value: impl AsRef<str>) -> RestyleImage

Apply the same restyling to all the traces

source

pub fn modify_text(values: Vec<impl AsRef<str>>) -> RestyleImage

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn text_array(self, value: Vec<impl AsRef<str>>) -> Box<Self>

Sets text elements associated with each (x,y) pair. If a single string, the same string appears over all the data points. If an array of strings the items are mapped in order to the this trace’s (x,y) coordinates. If the trace HoverInfo contains a “text” flag and hover_text is not set, these elements will be seen in the hover labels.

source

pub fn hover_text(self, value: impl AsRef<str>) -> Box<Self>

Sets hover text elements associated with each (x,y) pair. If a single string, the same string appears over all the data points. If an array of strings, the items are mapped in order to the this trace’s (x,y) coordinates. To be seen, trace HoverInfo must contain a “Text” flag.

source

pub fn modify_all_hover_text(value: impl AsRef<str>) -> RestyleImage

Apply the same restyling to all the traces

source

pub fn modify_hover_text(values: Vec<impl AsRef<str>>) -> RestyleImage

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn hover_text_array(self, value: Vec<impl AsRef<str>>) -> Box<Self>

Sets hover text elements associated with each (x,y) pair. If a single string, the same string appears over all the data points. If an array of strings, the items are mapped in order to the this trace’s (x,y) coordinates. To be seen, trace HoverInfo must contain a “Text” flag.

source

pub fn hover_info(self, value: HoverInfo) -> Box<Self>

Determines which trace information appear on hover. If HoverInfo::None or HoverInfo::Skip are set, no information is displayed upon hovering. But, if HoverInfo::None is set, click and hover events are still fired.

source

pub fn modify_all_hover_info(value: HoverInfo) -> RestyleImage

Apply the same restyling to all the traces

source

pub fn modify_hover_info(values: Vec<HoverInfo>) -> RestyleImage

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn hover_template(self, value: impl AsRef<str>) -> Box<Self>

Template string used for rendering the information that appear on hover box. Note that this will override HoverInfo. Variables are inserted using %{variable}, for example “y: %{y}”. Numbers are formatted using d3-format’s syntax %{variable:d3-format}, for example “Price: %{y:$.2f}”. https://github.com/d3/d3-3.x-api-reference/blob/master/Formatting.md#d3_format for details on the formatting syntax. Dates are formatted using d3-time-format’s syntax %{variable|d3-time-format}, for example “Day: %{2019-01-01|%A}”. https://github.com/d3/d3-3.x-api-reference/blob/master/Time-Formatting.md#format for details on the date formatting syntax. The variables available in hovertemplate are the ones emitted as event data described at this link https://plotly.com/javascript/plotlyjs-events/#event-data. Additionally, every attributes that can be specified per-point (the ones that are arrayOk: true) are available. Anything contained in tag <extra> is displayed in the secondary box, for example “{fullData.name}”. To hide the secondary box completely, use an empty tag <extra></extra>.

source

pub fn modify_all_hover_template(value: impl AsRef<str>) -> RestyleImage

Apply the same restyling to all the traces

source

pub fn modify_hover_template(values: Vec<impl AsRef<str>>) -> RestyleImage

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn hover_template_array(self, value: Vec<impl AsRef<str>>) -> Box<Self>

Template string used for rendering the information that appear on hover box. Note that this will override HoverInfo. Variables are inserted using %{variable}, for example “y: %{y}”. Numbers are formatted using d3-format’s syntax %{variable:d3-format}, for example “Price: %{y:$.2f}”. https://github.com/d3/d3-3.x-api-reference/blob/master/Formatting.md#d3_format for details on the formatting syntax. Dates are formatted using d3-time-format’s syntax %{variable|d3-time-format}, for example “Day: %{2019-01-01|%A}”. https://github.com/d3/d3-3.x-api-reference/blob/master/Time-Formatting.md#format for details on the date formatting syntax. The variables available in hovertemplate are the ones emitted as event data described at this link https://plotly.com/javascript/plotlyjs-events/#event-data. Additionally, every attributes that can be specified per-point (the ones that are arrayOk: true) are available. Anything contained in tag <extra> is displayed in the secondary box, for example “{fullData.name}”. To hide the secondary box completely, use an empty tag <extra></extra>.

source

pub fn meta(self, value: impl Into<NumOrString>) -> Box<Self>

Assigns extra meta information associated with this trace that can be used in various text attributes. Attributes such as trace name, graph, axis and colorbar title.text, annotation text rangeselector, updatemenues and sliders label text all support meta. To access the trace meta values in an attribute in the same trace, simply use %{meta[i]} where i is the index or key of the meta item in question. To access trace meta in layout attributes, use %{data[n[.meta[i]} where i is the index or key of the meta and n is the trace index.

source

pub fn modify_all_meta(value: impl Into<NumOrString>) -> RestyleImage

Apply the same restyling to all the traces

source

pub fn modify_meta(values: Vec<impl Into<NumOrString>>) -> RestyleImage

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn custom_data( self, value: Vec<impl Into<NumOrString> + Clone> ) -> Box<Self>

Assigns extra data each datum. This may be useful when listening to hover, click and selection events. Note that, “scatter” traces also appends customdata items in the markers DOM elements

source

pub fn modify_all_custom_data( value: Vec<impl Into<NumOrString> + Clone> ) -> RestyleImage

Apply the same restyling to all the traces

source

pub fn modify_custom_data( values: Vec<Vec<impl Into<NumOrString> + Clone>> ) -> RestyleImage

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn x_axis(self, value: impl AsRef<str>) -> Box<Self>

Sets a reference between this trace’s x coordinates and a 2D cartesian x axis. If “x” ( the default value), the x coordinates refer to Layout::x_axis. If “x2”, the x coordinates refer to Layout::x_axis2, and so on.

source

pub fn modify_all_x_axis(value: impl AsRef<str>) -> RestyleImage

Apply the same restyling to all the traces

source

pub fn modify_x_axis(values: Vec<impl AsRef<str>>) -> RestyleImage

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn y_axis(self, value: impl AsRef<str>) -> Box<Self>

Sets a reference between this trace’s y coordinates and a 2D cartesian y axis. If “y” (the default value), the y coordinates refer to Layout::y_axis. If “y2”, the y coordinates refer to Layout::y_axis2, and so on.

source

pub fn modify_all_y_axis(value: impl AsRef<str>) -> RestyleImage

Apply the same restyling to all the traces

source

pub fn modify_y_axis(values: Vec<impl AsRef<str>>) -> RestyleImage

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn color_model(self, value: ColorModel) -> Box<Self>

Color model used to map the numerical color components described in z into colors. If source is specified, this attribute will be set to rgba256 otherwise it defaults to rgb.

source

pub fn modify_all_color_model(value: ColorModel) -> RestyleImage

Apply the same restyling to all the traces

source

pub fn modify_color_model(values: Vec<ColorModel>) -> RestyleImage

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn z_smooth(self, value: ZSmooth) -> Box<Self>

Picks a smoothing algorithm used to smooth z data. This only applies for image traces that use the source attribute.

source

pub fn modify_all_z_smooth(value: ZSmooth) -> RestyleImage

Apply the same restyling to all the traces

source

pub fn modify_z_smooth(values: Vec<ZSmooth>) -> RestyleImage

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn hover_label(self, value: Label) -> Box<Self>

Properties of label displayed on mouse hover.

source

pub fn modify_all_hover_label(value: Label) -> RestyleImage

Apply the same restyling to all the traces

source

pub fn modify_hover_label(values: Vec<Label>) -> RestyleImage

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn ui_revision(self, value: impl Into<NumOrString>) -> Box<Self>

Controls persistence of some user-driven changes to the trace: constraintrange in parcoords traces, as well as some editable: True modifications such as name and colorbar.title. Defaults to layout.uirevision. Note that other user-driven trace attribute changes are controlled by layout attributes: trace.visible is controlled by layout.legend.uirevision, selectedpoints is controlled by layout.selectionrevision, and colorbar.(x|y) (accessible with config: {editable: True}) is controlled by layout.editrevision. Trace changes are tracked by uid, which only falls back on trace index if no uid is provided. So if your app can add/remove traces before the end of the data array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a uid that stays with it as it moves.

source

pub fn modify_all_ui_revision(value: impl Into<NumOrString>) -> RestyleImage

Apply the same restyling to all the traces

source

pub fn modify_ui_revision(values: Vec<impl Into<NumOrString>>) -> RestyleImage

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source§

impl Image

source

pub fn new(z: impl ImageData) -> Box<Self>

A 2-dimensional array in which each element is an array of 3 or 4 numbers representing a color.

source

pub fn z_max(self, z_max: impl ImageData) -> Box<Self>

Array defining the higher bound for each color component. Note that the default value will depend on the colormodel. For the rgb colormodel, it is [255, 255, 255]. For the rgba colormodel, it is [255, 255, 255, 1]. For the rgba256 colormodel, it is [255, 255, 255, 255]. For the hsl colormodel, it is [360, 100, 100]. For the hsla colormodel, it is [360, 100, 100, 1].

source

pub fn z_min(self, z_min: impl ImageData) -> Box<Self>

Array defining the lower bound for each color component. Note that the default value will depend on the colormodel. For the rgb colormodel, it is [0, 0, 0]. For the rgba colormodel, it is [0, 0, 0, 0]. For the rgba256 colormodel, it is [0, 0, 0, 0]. For the hsl colormodel, it is [0, 0, 0]. For the hsla colormodel, it is [0, 0, 0, 0].

Trait Implementations§

source§

impl Clone for Image

source§

fn clone(&self) -> Image

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Image

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Image

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Serialize for Image

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Trace for Image

source§

fn to_json(&self) -> String

Auto Trait Implementations§

§

impl !RefUnwindSafe for Image

§

impl Send for Image

§

impl Sync for Image

§

impl Unpin for Image

§

impl !UnwindSafe for Image

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> DynClone for Twhere T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Serialize for Twhere T: Serialize + ?Sized,

source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V