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
traceswith style and configuration fromlayoutandconfig.Traces to Layout Subplot Axis Association
Constructors collects subplot axis properties , i.e.
Trace.xAxis,Trace.yAxis,Trace.polarand so on, of each trace, checks for uniqueness and assigns them to the correspondingLayoutcontainer, i. e.Layout.xAxis,Layout.yAxis,Layout.polarand so on.The check for uniqueness is a little bit tricky and requires comparison against the
.presetstatic property. The.presetrepresents 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
uidcollision. 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 axisuids don’t look as expected.Note
The duplicate
uidassertion is excluded from release builds.Declaration
Parameters
tracesArray of traces that represent the data series displayed on the figure.
layoutSettings affecting layout of the figure, i.e. subplots, axis, title, scale, margin, ticks and more.
framesIf the figure isn’t animated, an empty array, or animation frames otherwise.
configConfiguration 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
.includedoption downloads the library from the CDN server and returns<script>tag with the file content.Declaration
Parameters
pathFile where to save the
Figureobject.formatOutput format (HTML, JSON, …)
bundleJavaScript 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
View on GitHub
Install in Dash
Figure Structure Reference