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
impl Image
sourcepub fn name(self, value: impl AsRef<str>) -> Box<Self>
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.
sourcepub fn modify_all_name(value: impl AsRef<str>) -> RestyleImage
pub fn modify_all_name(value: impl AsRef<str>) -> RestyleImage
Apply the same restyling to all the traces
sourcepub fn modify_name(values: Vec<impl AsRef<str>>) -> RestyleImage
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
sourcepub fn visible(self, value: Visible) -> Box<Self>
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).
sourcepub fn modify_all_visible(value: Visible) -> RestyleImage
pub fn modify_all_visible(value: Visible) -> RestyleImage
Apply the same restyling to all the traces
sourcepub fn modify_visible(values: Vec<Visible>) -> RestyleImage
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
sourcepub fn legend_rank(self, value: usize) -> Box<Self>
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.
sourcepub fn modify_all_legend_rank(value: usize) -> RestyleImage
pub fn modify_all_legend_rank(value: usize) -> RestyleImage
Apply the same restyling to all the traces
sourcepub fn modify_legend_rank(values: Vec<usize>) -> RestyleImage
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
sourcepub fn legend_group_title(self, value: LegendGroupTitle) -> Box<Self>
pub fn legend_group_title(self, value: LegendGroupTitle) -> Box<Self>
Set and style the title to appear for the legend group.
sourcepub fn modify_all_legend_group_title(value: LegendGroupTitle) -> RestyleImage
pub fn modify_all_legend_group_title(value: LegendGroupTitle) -> RestyleImage
Apply the same restyling to all the traces
sourcepub fn modify_legend_group_title(values: Vec<LegendGroupTitle>) -> RestyleImage
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
sourcepub fn modify_all_opacity(value: f64) -> RestyleImage
pub fn modify_all_opacity(value: f64) -> RestyleImage
Apply the same restyling to all the traces
sourcepub fn modify_opacity(values: Vec<f64>) -> RestyleImage
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
sourcepub fn ids(self, value: Vec<impl AsRef<str>>) -> Box<Self>
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.
sourcepub fn modify_all_ids(value: Vec<impl AsRef<str>>) -> RestyleImage
pub fn modify_all_ids(value: Vec<impl AsRef<str>>) -> RestyleImage
Apply the same restyling to all the traces
sourcepub fn modify_ids(values: Vec<Vec<impl AsRef<str>>>) -> RestyleImage
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
sourcepub fn modify_all_x0(value: impl Into<NumOrString>) -> RestyleImage
pub fn modify_all_x0(value: impl Into<NumOrString>) -> RestyleImage
Apply the same restyling to all the traces
sourcepub fn modify_x0(values: Vec<impl Into<NumOrString>>) -> RestyleImage
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
sourcepub fn modify_all_dx(value: f64) -> RestyleImage
pub fn modify_all_dx(value: f64) -> RestyleImage
Apply the same restyling to all the traces
sourcepub fn modify_dx(values: Vec<f64>) -> RestyleImage
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
sourcepub fn modify_all_y0(value: impl Into<NumOrString>) -> RestyleImage
pub fn modify_all_y0(value: impl Into<NumOrString>) -> RestyleImage
Apply the same restyling to all the traces
sourcepub fn modify_y0(values: Vec<impl Into<NumOrString>>) -> RestyleImage
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
sourcepub fn modify_all_dy(value: f64) -> RestyleImage
pub fn modify_all_dy(value: f64) -> RestyleImage
Apply the same restyling to all the traces
sourcepub fn modify_dy(values: Vec<f64>) -> RestyleImage
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
sourcepub fn source(self, value: impl AsRef<str>) -> Box<Self>
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/[
sourcepub fn modify_all_source(value: impl AsRef<str>) -> RestyleImage
pub fn modify_all_source(value: impl AsRef<str>) -> RestyleImage
Apply the same restyling to all the traces
sourcepub fn modify_source(values: Vec<impl AsRef<str>>) -> RestyleImage
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
sourcepub fn text(self, value: impl AsRef<str>) -> Box<Self>
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.
sourcepub fn modify_all_text(value: impl AsRef<str>) -> RestyleImage
pub fn modify_all_text(value: impl AsRef<str>) -> RestyleImage
Apply the same restyling to all the traces
sourcepub fn modify_text(values: Vec<impl AsRef<str>>) -> RestyleImage
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
sourcepub fn text_array(self, value: Vec<impl AsRef<str>>) -> Box<Self>
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.
sourcepub fn hover_text(self, value: impl AsRef<str>) -> Box<Self>
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.
sourcepub fn modify_all_hover_text(value: impl AsRef<str>) -> RestyleImage
pub fn modify_all_hover_text(value: impl AsRef<str>) -> RestyleImage
Apply the same restyling to all the traces
sourcepub fn modify_hover_text(values: Vec<impl AsRef<str>>) -> RestyleImage
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
sourcepub fn hover_text_array(self, value: Vec<impl AsRef<str>>) -> Box<Self>
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.
sourcepub fn hover_info(self, value: HoverInfo) -> Box<Self>
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.
sourcepub fn modify_all_hover_info(value: HoverInfo) -> RestyleImage
pub fn modify_all_hover_info(value: HoverInfo) -> RestyleImage
Apply the same restyling to all the traces
sourcepub fn modify_hover_info(values: Vec<HoverInfo>) -> RestyleImage
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
sourcepub fn hover_template(self, value: impl AsRef<str>) -> Box<Self>
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
“<extra></extra>
.
sourcepub fn modify_all_hover_template(value: impl AsRef<str>) -> RestyleImage
pub fn modify_all_hover_template(value: impl AsRef<str>) -> RestyleImage
Apply the same restyling to all the traces
sourcepub fn modify_hover_template(values: Vec<impl AsRef<str>>) -> RestyleImage
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
sourcepub fn hover_template_array(self, value: Vec<impl AsRef<str>>) -> Box<Self>
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
“<extra></extra>
.
sourcepub fn meta(self, value: impl Into<NumOrString>) -> Box<Self>
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.
sourcepub fn modify_all_meta(value: impl Into<NumOrString>) -> RestyleImage
pub fn modify_all_meta(value: impl Into<NumOrString>) -> RestyleImage
Apply the same restyling to all the traces
sourcepub fn modify_meta(values: Vec<impl Into<NumOrString>>) -> RestyleImage
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
sourcepub fn custom_data(
self,
value: Vec<impl Into<NumOrString> + Clone>
) -> Box<Self>
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
sourcepub fn modify_all_custom_data(
value: Vec<impl Into<NumOrString> + Clone>
) -> RestyleImage
pub fn modify_all_custom_data( value: Vec<impl Into<NumOrString> + Clone> ) -> RestyleImage
Apply the same restyling to all the traces
sourcepub fn modify_custom_data(
values: Vec<Vec<impl Into<NumOrString> + Clone>>
) -> RestyleImage
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
sourcepub fn x_axis(self, value: impl AsRef<str>) -> Box<Self>
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.
sourcepub fn modify_all_x_axis(value: impl AsRef<str>) -> RestyleImage
pub fn modify_all_x_axis(value: impl AsRef<str>) -> RestyleImage
Apply the same restyling to all the traces
sourcepub fn modify_x_axis(values: Vec<impl AsRef<str>>) -> RestyleImage
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
sourcepub fn y_axis(self, value: impl AsRef<str>) -> Box<Self>
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.
sourcepub fn modify_all_y_axis(value: impl AsRef<str>) -> RestyleImage
pub fn modify_all_y_axis(value: impl AsRef<str>) -> RestyleImage
Apply the same restyling to all the traces
sourcepub fn modify_y_axis(values: Vec<impl AsRef<str>>) -> RestyleImage
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
sourcepub fn color_model(self, value: ColorModel) -> Box<Self>
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
.
sourcepub fn modify_all_color_model(value: ColorModel) -> RestyleImage
pub fn modify_all_color_model(value: ColorModel) -> RestyleImage
Apply the same restyling to all the traces
sourcepub fn modify_color_model(values: Vec<ColorModel>) -> RestyleImage
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
sourcepub fn z_smooth(self, value: ZSmooth) -> Box<Self>
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.
sourcepub fn modify_all_z_smooth(value: ZSmooth) -> RestyleImage
pub fn modify_all_z_smooth(value: ZSmooth) -> RestyleImage
Apply the same restyling to all the traces
sourcepub fn modify_z_smooth(values: Vec<ZSmooth>) -> RestyleImage
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
sourcepub fn hover_label(self, value: Label) -> Box<Self>
pub fn hover_label(self, value: Label) -> Box<Self>
Properties of label displayed on mouse hover.
sourcepub fn modify_all_hover_label(value: Label) -> RestyleImage
pub fn modify_all_hover_label(value: Label) -> RestyleImage
Apply the same restyling to all the traces
sourcepub fn modify_hover_label(values: Vec<Label>) -> RestyleImage
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
sourcepub fn ui_revision(self, value: impl Into<NumOrString>) -> Box<Self>
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.
sourcepub fn modify_all_ui_revision(value: impl Into<NumOrString>) -> RestyleImage
pub fn modify_all_ui_revision(value: impl Into<NumOrString>) -> RestyleImage
Apply the same restyling to all the traces
sourcepub fn modify_ui_revision(values: Vec<impl Into<NumOrString>>) -> RestyleImage
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
impl Image
sourcepub fn new(z: impl ImageData) -> Box<Self>
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.
sourcepub fn z_max(self, z_max: impl ImageData) -> Box<Self>
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].
sourcepub fn z_min(self, z_min: impl ImageData) -> Box<Self>
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].