PlotlyLight.jl

A lightweight interface for creating Plotly.js plots from Julia
Author joshday
Popularity
1 Star
Updated Last
1 Year Ago
Started In
March 2020

PlotlyLight

PlotlyLight is an ultra-lightweight (<100 lines) interface for working with Plotly.js.


  • Plotly's Javascript API requires three components: data, layout, and config.
  • PlotlyLight.Plot simply does EasyConfig.Config-to-JSON conversion for each of the three components.
using PlotlyLight

data = Config(x = 1:10, y = randn(10))

layout = Config()
layout.title.text = "My Title!"

Plot(data, layout)

Display

To display a PlotlyLight.Plot, you must be in an environment that can utilize text/html mimetypes (like Pluto.jl.

Alternatively, it's straightforward to implement your own display method:

DefaultApplication.jl (HTML)

using PlotlyLight, DefaultApplication

function f(p::Plot) 
    filename = joinpath(tempdir(), "temp.html")
    file = write(filename, PlotlyLight.html(p))
    DefaultApplication.open(filename)
end

p = Plot(Config(x = 1:10, y = randn(10)))

f(p)

Blink.jl

using Blink, PlotlyLight

w = Window()

load!(w, "https://cdn.plot.ly/plotly-latest.min.js")

f(p) = body!(w, p)

f(Plot(Config(x = 1:10, y = randn(10))))

Used By Packages

No packages found.