Image

public struct Image<ZData> : Trace, XYSubplot where ZData : Plotable

Display an image, i.e.

data on a 2D regular raster. By default, when an image is displayed in a subplot, its y axis will be reversed (ie. autorange: 'reversed'), constrained to the domain (ie. constrain: 'domain') and it will have the same scale as its x axis (ie. scaleanchor: 'x,) in order for pixels to be rendered as squares.

See also

Documentation for Python, JavaScript or R
  • Corresponding Plotly trace type.

    Declaration

    Swift

    public let type: String
  • Switch indicating whether the trace supports animation of its data.

    Declaration

    Swift

    public static var animatable: Bool { get }
  • Determines whether or not this trace is visible.

    If legendonly, the trace is not drawn, but can appear as a legend item (provided that the legend itself is visible).

    Declaration

    Swift

    public var visible: Visible?
  • Sets the opacity of the trace.

    Declaration

    Swift

    public var opacity: Double?
  • Sets the trace name.

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

    Declaration

    Swift

    public var name: String?
  • uid

    Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.

    Declaration

    Swift

    public var uid: String?
  • ids

    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.

    Declaration

    Swift

    public var ids: [String]?
  • 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

    Declaration

    Swift

    public var customData: [String]?
  • 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.

    Declaration

    Swift

    public var meta: Data<Anything>?
  • Undocumented

    Declaration

    Swift

    public var hoverLabel: HoverLabel?
  • Undocumented

    Declaration

    Swift

    public var stream: Stream?
  • 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.

    Declaration

    Swift

    public var uiRevision: Anything?
  • Specifies the data URI of the image to be visualized.

    The URI consists of “data:image/[][;base64],

    Declaration

    Swift

    public var source: String?
  • z

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

    Declaration

    Swift

    public var z: ZData?
  • 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.

    See more

    Declaration

    Swift

    public enum ColorModel : String, Encodable
  • 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.

    Declaration

    Swift

    public var colorModel: ColorModel?
  • 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].

    Declaration

    Swift

    public var zMin: InfoArray?
  • 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].

    Declaration

    Swift

    public var zMax: InfoArray?
  • x0

    Set the image’s x position.

    Declaration

    Swift

    public var x0: Anything?
  • y0

    Set the image’s y position.

    Declaration

    Swift

    public var y0: Anything?
  • dx

    Set the pixel’s horizontal size.

    Declaration

    Swift

    public var dx: Double?
  • dy

    Set the pixel’s vertical size

    Declaration

    Swift

    public var dy: Double?
  • Sets the text elements associated with each z value.

    Declaration

    Swift

    public var text: Data<String>?
  • Same as text.

    Declaration

    Swift

    public var hoverText: Data<String>?
  • Determines which trace information appear on hover.

    If none or skip are set, no information is displayed upon hovering. But, if none is set, click and hover events are still fired.

    See more

    Declaration

    Swift

    public struct HoverInfo : OptionSet, Encodable
  • Determines which trace information appear on hover.

    If none or skip are set, no information is displayed upon hovering. But, if none is set, click and hover events are still fired.

    Declaration

    Swift

    public var hoverInfo: HoverInfo?
  • 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-time-format#locale_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. variables z, color and colormodel. 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>.

    Declaration

    Swift

    public var hoverTemplate: Data<String>?
  • 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.xaxis. If x2, the x coordinates refer to layout.xaxis2, and so on.

    Declaration

    Swift

    public var xAxis: XAxis
  • 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.yaxis. If y2, the y coordinates refer to layout.yaxis2, and so on.

    Declaration

    Swift

    public var yAxis: YAxis
  • Creates Image object from the most frequently used properties.

    Declaration

    Swift

    public init(name: String? = nil, z: ZData? = nil, text: Data<String>? = nil, hoverText:
            Data<String>? = nil)

    Parameters

    name

    Sets the trace name.

    z

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

    text

    Sets the text elements associated with each z value.

    hoverText

    Same as text.

  • Creates Image object with specified properties.

    Declaration

    Swift

    public init(visible: Visible? = nil, opacity: Double? = nil, name: String? = nil, uid: String? =
            nil, ids: [String]? = nil, customData: [String]? = nil, meta: Data<Anything>? = nil, hoverLabel:
            HoverLabel? = nil, stream: Stream? = nil, uiRevision: Anything? = nil, source: String? = nil, z:
            ZData? = nil, colorModel: ColorModel? = nil, zMin: InfoArray? = nil, zMax: InfoArray? = nil, x0:
            Anything? = nil, y0: Anything? = nil, dx: Double? = nil, dy: Double? = nil, text: Data<String>?
            = nil, hoverText: Data<String>? = nil, hoverInfo: HoverInfo? = nil, hoverTemplate: Data<String>?
            = nil, xAxis: XAxis = .preset, yAxis: YAxis = .preset)

    Parameters

    visible

    Determines whether or not this trace is visible.

    opacity

    Sets the opacity of the trace.

    name

    Sets the trace name.

    uid

    Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.

    ids

    Assigns id labels to each datum.

    customData

    Assigns extra data each datum.

    meta

    Assigns extra meta information associated with this trace that can be used in various text attributes.

    hoverLabel

    stream

    uiRevision

    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.

    source

    Specifies the data URI of the image to be visualized.

    z

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

    colorModel

    Color model used to map the numerical color components described in z into colors.

    zMin

    Array defining the lower bound for each color component.

    zMax

    Array defining the higher bound for each color component.

    x0

    Set the image’s x position.

    y0

    Set the image’s y position.

    dx

    Set the pixel’s horizontal size.

    dy

    Set the pixel’s vertical size

    text

    Sets the text elements associated with each z value.

    hoverText

    Same as text.

    hoverInfo

    Determines which trace information appear on hover.

    hoverTemplate

    Template string used for rendering the information that appear on hover box.

    xAxis

    Sets a reference between this trace’s x coordinates and a 2D cartesian x axis.

    yAxis

    Sets a reference between this trace’s y coordinates and a 2D cartesian y axis.

  • Encodes the object in a format compatible with Plotly.

    Declaration

    Swift

    public func encode(to encoder: Encoder) throws