PlotlyDocumenter

Documentation for PlotlyDocumenter.

This package provides a function to_documenter that returns a wrapped plot object. This object will be rendered interactively by Documenter. If you are using DocumenterVitepress, see here for more information.

Note

To prevent to_documenter from showing up in the documentation, add #hide to the end of the line. See Documenter.jl for more information.

API

PlotlyDocumenter.PlotlyDocumenterPlotType
PlotlyDocumenterPlot

A wrapper type for Plotly plot data that enables flexible rendering in different contexts.

The plot data is stored as strings containing the JSON representation of the plot's data, layout and config.

The options field contains rendering options that control how the plot is displayed. For the default text/html MIME output, see to_documenter for more information.

source
PlotlyDocumenter.to_documenterMethod
to_documenter(p::P; id, version)

Take a plot object p and returns an output that is showable as HTML inside pages generated from Documenter.jl. This function currently works correctly inside @example blocks from Documenter.jl if called as last statement/command. Check the package documentation for seeing it in action.

The object returned as output, when shown as text/html, will generate a plotly plot can be interacted with directly in the documentation page.

This package supports the following types as P:

  • Plot from PlotlyBase
  • SyncPlot from PlotlyBase
  • Plot from PlotlyLight

Keyword Arguments

  • id: The id to be given to the div containing the plot. Defaults to a random string of 10 alphanumeric characters
  • version: Version of plotly.js to use. Defaults to version 2.24.2, but can be overridden by providing version as a string. To change the default version, use the unexported change_default_plotly_version function.
  • classes: A Vector of Strings representing classes to assign the div containing the plot. Defaults to an empty vector
  • style: An object containing a list of styles that are applied inline to the plot object. Defaults to an empty NTuple. Supports the synthax of HypertextLiteral

Notes

  • The package does not reexport any plotting packages, so the desired plotting package must be brought in to scope independently.
  • The package currently only supports fetching the plotly library from CDN, so it does not support local version of Plotly (even though they are supported by PlotlyLight for example)
source

Examples

PlotlyBase

using PlotlyDocumenter
using PlotlyBase

p = Plot(scatter(;y = rand(5)))
to_documenter(p)

PlotlyJS

using PlotlyDocumenter
using PlotlyJS

p = plot(scatter(;y = rand(5)), Layout(height = 700))
to_documenter(p)

PlotlyLight

using PlotlyDocumenter
using PlotlyLight

p = Plot(;y = rand(5), type = "scatter")
to_documenter(p)