Figure
public struct Figure
extension Figure: CustomPlaygroundDisplayConvertible
extension Figure: Encodable
Representation of a Plotly chart.
Plotly‘s graphs are built from two main types of building blocks - traces and layout. Trace describes a single series of data visible in a graph. Traces can be constructed from a wide variety of predefined types, e.g. scatter, heatmap, bar or polar. Layout applies to the entire chart and affect properties like the title, axis annotations and many more.
-
Structure containing layout of the figure.
Declaration
Swift
public var layout: Layout
-
Structure storing Plotly configuration.
Declaration
Swift
public var config: Config
-
Collection of animation frames.
Declaration
Swift
public var frames: [Frame]
-
Output format specification.
See moreDeclaration
Swift
public enum Format
-
Creates a chart displaying the data series from
traces
with style and configuration fromlayout
andconfig
.Traces to Layout Subplot Axis Association
Constructors collects subplot axis properties , i.e.
Trace.xAxis
,Trace.yAxis
,Trace.polar
and so on, of each trace, checks for uniqueness and assigns them to the correspondingLayout
container, i. e.Layout.xAxis
,Layout.yAxis
,Layout.polar
and so on.The check for uniqueness is a little bit tricky and requires comparison against the
.preset
static property. The.preset
represents the default value implicitly used by Plotly when the subplot axis property isn’t set.If a pair of colliding subplot axis is found, the constructor issues an assertion to alert the user about the
uid
collision. This error means that traces or layout have independent subplot axis with the sameuid
. This is a serious and hard to find error in Plotly.js because figures with duplicated axisuid
s don’t look as expected.Note
The duplicate
uid
assertion is excluded from release builds.Declaration
Parameters
traces
Array of traces that represent the data series displayed on the figure.
layout
Settings affecting layout of the figure, i.e. subplots, axis, title, scale, margin, ticks and more.
frames
If the figure isn’t animated, an empty array, or animation frames otherwise.
config
Configuration of the Plotly library, i.e. toolbar, watermark, scrolling, locale and more.
-
Shows the chart in the default browser.
Here’s an example that shows figure with a scatter trace:
let scatterTrace = Scatter(x: [1, 2, 3], y: [4, 6, 5]) let figure = Figure(data: [scatterTrace]) try figure.show()
Declaration
Swift
@available(iOS 10.0, *) public func show(javaScript bundle: HTML.JavaScriptBundleOption = .online) throws
-
Writes chart to a URL using the specified format.
Warning
Execution may take a few seconds because the function needs internet access. Current implementation of
.included
option downloads the library from the CDN server and returns<script>
tag with the file content.Declaration
Parameters
path
File where to save the
Figure
object.format
Output format (HTML, JSON, …)
bundle
JavaScript bundling option (i.e. include, online, exclude) for MathJax and Plotly libraries. Used only for HTML format.
-
Undocumented
Declaration
Swift
func debugQuickLookObject() -> AnyObject
-
Declaration
Swift
public var playgroundDescription: Any { get }
-
Declaration
Swift
public func encode(to encoder: Encoder) throws