PlotlyJS.jl is a Julia wrapper for the interactive JavaScript plotting library plotly.js. It provides two main layers: 1) a faithful representation of the plotly.js API to allow constructing plots and visualizations programmatically in JSON format, and 2) convenience functions and syntax to make common plotting tasks more natural in Julia, such as plotting data with a single function call or combining multiple plots into subplots. The library aims to make interactive visualization easy and publication-quality from Julia.
6. In [2]: f(x, y) = "Two arguments: $(x) and $(y)"
f("hello", "plotcon")
Out[2]: "Two arguments: hello and plotcon"
7. In [3]:
In [4]:
In [5]:
In [6]:
f(x::Number, y) = "First arg is a number ($(x)), second isn't ($(y))"
# still old method
f("hello", "plotcon")
# new method
f(2, "plotcon")
# Generics
# also new method, but this time with floating point first argument
f(2.0, "plotcon")
Out[3]: f (generic function with 2 methods)
Out[4]: "Two arguments: hello and plotcon"
Out[5]: "First arg is a number (2), second isn't (plotcon)"
Out[6]: "First arg is a number (2.0), second isn't (plotcon)"
8. In [7]:
In [8]:
In [9]:
# longer function syntax
function f(x::Number, y::Number)
"Two numbers: ($(x), $(y))"
end
# newest method
f(2.0, 2)
# unsigned 8 bit int and BigInt
f(0x81, big(4))
Out[7]: f (generic function with 3 methods)
Out[8]: "Two numbers: (2.0, 2)"
Out[9]: "Two numbers: (129, 4)"
21. In [18]: # layout optional
plot(trace2)
Out[18]:
22. In [19]: # more than one trace
plot([trace1, trace3], layout)
Out[19]:
23. Convenience API
The plot function has a number of other methods that try to make it a bit easier to
construct simple plots (remember multiple dispatch? :) )
In [20]: methods(plot)
Out[20]: 13 methods for generic function plot:
plot{T<:Number,T2<:Number}(x::AbstractArray{T,1},
y::AbstractArray{T2,2}) at
plot{T<:Number,T2<:Number}(x::AbstractArray{T,1},
y::AbstractArray{T2,2}, l::PlotlyJS.Layout; style, kwargs...) at
plot{T<:Number,T2<:Number}(x::AbstractArray{T,2},
y::AbstractArray{T2,2}) at
plot{T<:Number,T2<:Number}(x::AbstractArray{T,2},
y::AbstractArray{T2,2}, l::PlotlyJS.Layout; style, kwargs...) at
/Users/sglyon/.julia/v0.5/PlotlyJS/src/convenience_api.jl:31
/Users/sglyon/.julia/v0.5/PlotlyJS/src/convenience_api.jl:31
/Users/sglyon/.julia/v0.5/PlotlyJS/src/convenience_api.jl:40
/Users/sglyon/.julia/v0.5/PlotlyJS/src/convenience_api.jl:40
42. Electron
We use to provide an app for PlotlyJS.jl
This buys us at least 2 things:
1. Dedicated GUI that we completely control
2. Full 2-way communication with javascript
Javascript interop enables:
Live updates of trace or layout attributes
Extending traces or adding new traces to a displayed plot
Raw svg output from d3.js for conversion to pdf, png, jpeg, eps, etc.
More...
Demo
Blink.jl Electron