Merge 3b3e4492fe6bed66b0049f856aeb6dc016802b28 into 1db2d8d8d84289e58af669b003dde3543a259695
This commit is contained in:
commit
ac2848c8c4
90
src/backends/glvisualize.jl
Normal file
90
src/backends/glvisualize.jl
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
|
||||||
|
|
||||||
|
# [WEBSITE]
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
immutable GLScreenWrapper
|
||||||
|
window
|
||||||
|
render
|
||||||
|
end
|
||||||
|
|
||||||
|
function _create_plot(pkg::GLVisualizePackage; kw...)
|
||||||
|
d = Dict(kw)
|
||||||
|
# TODO: create the window/canvas/context that is the plot within the backend (call it `o`)
|
||||||
|
# TODO: initialize the plot... title, xlabel, bgcolor, etc
|
||||||
|
w,r=GLVisualize.glscreen()
|
||||||
|
@async r()
|
||||||
|
Plot(GLScreenWrapper(w,r), pkg, 0, d, Dict[])
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function _add_series(::GLVisualizePackage, plt::Plot; kw...)
|
||||||
|
d = Dict(kw)
|
||||||
|
# TODO: add one series to the underlying package
|
||||||
|
push!(plt.seriesargs, d)
|
||||||
|
x,y,z=map(Float32,d[:x]), map(Float32,d[:y]), map(Float32,d[:surface].surf)
|
||||||
|
GLVisualize.view(GLVisualize.visualize(x*ones(y)', ones(x)*y', z, :surface))
|
||||||
|
plt
|
||||||
|
end
|
||||||
|
|
||||||
|
function _add_annotations{X,Y,V}(plt::Plot{GLVisualizePackage}, anns::AVec{@compat(Tuple{X,Y,V})})
|
||||||
|
for ann in anns
|
||||||
|
# TODO: add the annotation to the plot
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
|
function _before_update_plot(plt::Plot{GLVisualizePackage})
|
||||||
|
end
|
||||||
|
|
||||||
|
# TODO: override this to update plot items (title, xlabel, etc) after creation
|
||||||
|
function _update_plot(plt::Plot{GLVisualizePackage}, d::Dict)
|
||||||
|
end
|
||||||
|
|
||||||
|
function _update_plot_pos_size(plt::PlottingObject{GLVisualizePackage}, d::Dict)
|
||||||
|
end
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
|
# accessors for x/y data
|
||||||
|
|
||||||
|
function Base.getindex(plt::Plot{GLVisualizePackage}, i::Int)
|
||||||
|
series = plt.o.lines[i]
|
||||||
|
series.x, series.y
|
||||||
|
end
|
||||||
|
|
||||||
|
function Base.setindex!(plt::Plot{GLVisualizePackage}, xy::Tuple, i::Integer)
|
||||||
|
series = plt.o.lines[i]
|
||||||
|
series.x, series.y = xy
|
||||||
|
plt
|
||||||
|
end
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
|
function _create_subplot(subplt::Subplot{GLVisualizePackage})
|
||||||
|
# TODO: build the underlying Subplot object. this is where you might layout the panes within a GUI window, for example
|
||||||
|
end
|
||||||
|
|
||||||
|
function _expand_limits(lims, plt::Plot{GLVisualizePackage}, isx::Bool)
|
||||||
|
# TODO: call expand limits for each plot data
|
||||||
|
end
|
||||||
|
|
||||||
|
function _remove_axis(plt::Plot{GLVisualizePackage}, isx::Bool)
|
||||||
|
# TODO: if plot is inner subplot, might need to remove ticks or axis labels
|
||||||
|
end
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
|
function Base.writemime(io::IO, ::MIME"image/png", plt::PlottingObject{GLVisualizePackage})
|
||||||
|
# TODO: write a png to io
|
||||||
|
end
|
||||||
|
|
||||||
|
function Base.display(::PlotsDisplay, plt::Plot{GLVisualizePackage})
|
||||||
|
# TODO: display/show the plot
|
||||||
|
end
|
||||||
|
|
||||||
|
function Base.display(::PlotsDisplay, plt::Subplot{GLVisualizePackage})
|
||||||
|
# TODO: display/show the subplot
|
||||||
|
end
|
||||||
@ -75,7 +75,7 @@ supportedArgs(::GadflyPackage) = [
|
|||||||
:nlevels,
|
:nlevels,
|
||||||
]
|
]
|
||||||
supportedAxes(::GadflyPackage) = [:auto, :left]
|
supportedAxes(::GadflyPackage) = [:auto, :left]
|
||||||
supportedTypes(::GadflyPackage) = [:none, :line, :path, :steppre, :steppost, :sticks,
|
supportedTypes(::GadflyPackage) = [:none, :line, :path, :steppre, :steppost, :sticks,
|
||||||
:scatter, :heatmap, :hexbin, :hist, :bar,
|
:scatter, :heatmap, :hexbin, :hist, :bar,
|
||||||
:hline, :vline, :contour]
|
:hline, :vline, :contour]
|
||||||
supportedStyles(::GadflyPackage) = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
|
supportedStyles(::GadflyPackage) = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
|
||||||
@ -487,3 +487,68 @@ supportedScales(::PlotlyPackage) = [:identity, :log] #, :log, :log2, :log10, :as
|
|||||||
subplotSupported(::PlotlyPackage) = false
|
subplotSupported(::PlotlyPackage) = false
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
supportedArgs(::GLVisualizePackage) = [
|
||||||
|
# :annotation,
|
||||||
|
# :axis,
|
||||||
|
# :background_color,
|
||||||
|
# :color_palette,
|
||||||
|
# :fillrange,
|
||||||
|
# :fillcolor,
|
||||||
|
# :fillalpha,
|
||||||
|
# :foreground_color,
|
||||||
|
# :group,
|
||||||
|
# :label,
|
||||||
|
# :layout,
|
||||||
|
# :legend,
|
||||||
|
# :linecolor,
|
||||||
|
# :linestyle,
|
||||||
|
# :linetype,
|
||||||
|
# :linewidth,
|
||||||
|
# :linealpha,
|
||||||
|
# :markershape,
|
||||||
|
# :markercolor,
|
||||||
|
# :markersize,
|
||||||
|
# :markeralpha,
|
||||||
|
# :markerstrokewidth,
|
||||||
|
# :markerstrokecolor,
|
||||||
|
# :markerstrokestyle,
|
||||||
|
# :n,
|
||||||
|
# :nbins,
|
||||||
|
# :nc,
|
||||||
|
# :nr,
|
||||||
|
# :pos,
|
||||||
|
# :smooth,
|
||||||
|
# :show,
|
||||||
|
# :size,
|
||||||
|
# :title,
|
||||||
|
# :windowtitle,
|
||||||
|
# :x,
|
||||||
|
# :xlabel,
|
||||||
|
# :xlims,
|
||||||
|
# :xticks,
|
||||||
|
# :y,
|
||||||
|
# :ylabel,
|
||||||
|
# :ylims,
|
||||||
|
# :yrightlabel,
|
||||||
|
# :yticks,
|
||||||
|
# :xscale,
|
||||||
|
# :yscale,
|
||||||
|
# :xflip,
|
||||||
|
# :yflip,
|
||||||
|
# :z,
|
||||||
|
# :tickfont,
|
||||||
|
# :guidefont,
|
||||||
|
# :legendfont,
|
||||||
|
# :grid,
|
||||||
|
# :surface
|
||||||
|
# :nlevels,
|
||||||
|
]
|
||||||
|
supportedAxes(::GLVisualizePackage) = [:auto, :left]
|
||||||
|
supportedTypes(::GLVisualizePackage) = [:contour] #, :path, :scatter ,:steppre, :steppost, :sticks, :heatmap, :hexbin, :hist, :bar, :hline, :vline, :contour]
|
||||||
|
supportedStyles(::GLVisualizePackage) = [:auto, :solid] #, :dash, :dot, :dashdot, :dashdotdot]
|
||||||
|
supportedMarkers(::GLVisualizePackage) = [:none, :auto, :ellipse] #, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5] #vcat(_allMarkers, Shape)
|
||||||
|
supportedScales(::GLVisualizePackage) = [:identity] #, :log, :log2, :log10, :asinh, :sqrt]
|
||||||
|
subplotSupported(::GLVisualizePackage) = false
|
||||||
|
|||||||
15
src/plot.jl
15
src/plot.jl
@ -91,7 +91,7 @@ function plot!(plt::Plot, args...; kw...)
|
|||||||
|
|
||||||
# get the list of dictionaries, one per series
|
# get the list of dictionaries, one per series
|
||||||
seriesArgList, xmeta, ymeta = createKWargsList(plt, groupargs..., args...; d...)
|
seriesArgList, xmeta, ymeta = createKWargsList(plt, groupargs..., args...; d...)
|
||||||
|
|
||||||
# if we were able to extract guide information from the series inputs, then update the plot
|
# if we were able to extract guide information from the series inputs, then update the plot
|
||||||
# @show xmeta, ymeta
|
# @show xmeta, ymeta
|
||||||
updateDictWithMeta(d, plt.plotargs, xmeta, true)
|
updateDictWithMeta(d, plt.plotargs, xmeta, true)
|
||||||
@ -372,6 +372,16 @@ function createKWargsList{T<:Real}(plt::PlottingObject, x::AVec, y::AVec, zmat::
|
|||||||
createKWargsList(plt, x, y; kw..., surface = surf, linetype = :contour)
|
createKWargsList(plt, x, y; kw..., surface = surf, linetype = :contour)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# contours or surfaces... general x, y grid
|
||||||
|
function createKWargsList{T<:Real}(plt::PlottingObject, x::AMat{T}, y::AMat{T}, zmat::AMat{T}; kw...)
|
||||||
|
@assert size(zmat) == size(x) == size(y)
|
||||||
|
surf = Surface(convert(Matrix{Float64}, zmat))
|
||||||
|
# surf = Array(Any,1,1)
|
||||||
|
# surf[1,1] = convert(Matrix{Float64}, zmat)
|
||||||
|
createKWargsList(plt, x, y; kw..., surface = surf, linetype = :contour)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function createKWargsList(plt::PlottingObject, surf::Surface; kw...)
|
function createKWargsList(plt::PlottingObject, surf::Surface; kw...)
|
||||||
createKWargsList(plt, 1:size(surf.surf,1), 1:size(surf.surf,2), convert(Matrix{Float64}, surf.surf); kw...)
|
createKWargsList(plt, 1:size(surf.surf,1), 1:size(surf.surf,2), convert(Matrix{Float64}, surf.surf); kw...)
|
||||||
end
|
end
|
||||||
@ -411,7 +421,7 @@ function createKWargsList(plt::PlottingObject; kw...)
|
|||||||
return [], nothing, nothing
|
return [], nothing, nothing
|
||||||
# error("Called plot/subplot without args... must set y in the keyword args. Example: plot(; y=rand(10))")
|
# error("Called plot/subplot without args... must set y in the keyword args. Example: plot(; y=rand(10))")
|
||||||
end
|
end
|
||||||
|
|
||||||
if haskey(d, :x)
|
if haskey(d, :x)
|
||||||
return createKWargsList(plt, d[:x], d[:y]; kw...)
|
return createKWargsList(plt, d[:x], d[:y]; kw...)
|
||||||
else
|
else
|
||||||
@ -454,4 +464,3 @@ end
|
|||||||
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@ -8,6 +8,7 @@ immutable UnicodePlotsPackage <: PlottingPackage end
|
|||||||
immutable WinstonPackage <: PlottingPackage end
|
immutable WinstonPackage <: PlottingPackage end
|
||||||
immutable BokehPackage <: PlottingPackage end
|
immutable BokehPackage <: PlottingPackage end
|
||||||
immutable PlotlyPackage <: PlottingPackage end
|
immutable PlotlyPackage <: PlottingPackage end
|
||||||
|
immutable GLVisualizePackage <: PlottingPackage end
|
||||||
immutable NoPackage <: PlottingPackage end
|
immutable NoPackage <: PlottingPackage end
|
||||||
|
|
||||||
typealias GadflyOrImmerse @compat(Union{GadflyPackage, ImmersePackage})
|
typealias GadflyOrImmerse @compat(Union{GadflyPackage, ImmersePackage})
|
||||||
@ -19,7 +20,8 @@ export
|
|||||||
qwt,
|
qwt,
|
||||||
unicodeplots,
|
unicodeplots,
|
||||||
bokeh,
|
bokeh,
|
||||||
plotly
|
plotly,
|
||||||
|
glvisualize
|
||||||
# winston
|
# winston
|
||||||
|
|
||||||
gadfly() = backend(:gadfly)
|
gadfly() = backend(:gadfly)
|
||||||
@ -29,6 +31,7 @@ qwt() = backend(:qwt)
|
|||||||
unicodeplots() = backend(:unicodeplots)
|
unicodeplots() = backend(:unicodeplots)
|
||||||
bokeh() = backend(:bokeh)
|
bokeh() = backend(:bokeh)
|
||||||
plotly() = backend(:plotly)
|
plotly() = backend(:plotly)
|
||||||
|
glvisualize() = backend(:glvisualize)
|
||||||
# winston() = backend(:winston)
|
# winston() = backend(:winston)
|
||||||
|
|
||||||
backend_name(::GadflyPackage) = :gadfly
|
backend_name(::GadflyPackage) = :gadfly
|
||||||
@ -38,6 +41,7 @@ backend_name(::UnicodePlotsPackage) = :unicodeplots
|
|||||||
backend_name(::QwtPackage) = :qwt
|
backend_name(::QwtPackage) = :qwt
|
||||||
backend_name(::BokehPackage) = :bokeh
|
backend_name(::BokehPackage) = :bokeh
|
||||||
backend_name(::PlotlyPackage) = :plotly
|
backend_name(::PlotlyPackage) = :plotly
|
||||||
|
backend_name(::GLVisualizePackage) = :glvisualize
|
||||||
backend_name(::NoPackage) = :none
|
backend_name(::NoPackage) = :none
|
||||||
|
|
||||||
include("backends/supported.jl")
|
include("backends/supported.jl")
|
||||||
@ -49,6 +53,7 @@ include("backends/pyplot.jl")
|
|||||||
include("backends/immerse.jl")
|
include("backends/immerse.jl")
|
||||||
include("backends/winston.jl")
|
include("backends/winston.jl")
|
||||||
include("backends/bokeh.jl")
|
include("backends/bokeh.jl")
|
||||||
|
include("backends/glvisualize.jl")
|
||||||
# include("backends/plotly.jl")
|
# include("backends/plotly.jl")
|
||||||
|
|
||||||
|
|
||||||
@ -83,9 +88,10 @@ function backendInstance(sym::Symbol)
|
|||||||
sym == :winston && return WinstonPackage()
|
sym == :winston && return WinstonPackage()
|
||||||
sym == :bokeh && return BokehPackage()
|
sym == :bokeh && return BokehPackage()
|
||||||
sym == :plotly && return PlotlyPackage()
|
sym == :plotly && return PlotlyPackage()
|
||||||
|
sym == :glvisualize && return GLVisualizePackage()
|
||||||
sym == :none && return NoPackage()
|
sym == :none && return NoPackage()
|
||||||
error("Unsupported backend $sym")
|
error("Unsupported backend $sym")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
type CurrentBackend
|
type CurrentBackend
|
||||||
@ -132,7 +138,7 @@ CurrentBackend(sym::Symbol) = CurrentBackend(sym, backendInstance(sym))
|
|||||||
# end
|
# end
|
||||||
|
|
||||||
function pickDefaultBackend()
|
function pickDefaultBackend()
|
||||||
for pkgstr in ("PyPlot", "Immerse", "Qwt", "Gadfly", "UnicodePlots", "Bokeh")
|
for pkgstr in ("PyPlot", "Immerse", "Qwt", "Gadfly", "UnicodePlots", "Bokeh", "GLVisualize")
|
||||||
if Pkg.installed(pkgstr) != nothing
|
if Pkg.installed(pkgstr) != nothing
|
||||||
return backend(symbol(lowercase(pkgstr)))
|
return backend(symbol(lowercase(pkgstr)))
|
||||||
end
|
end
|
||||||
@ -196,7 +202,7 @@ function backend()
|
|||||||
# @eval const pycolorbar = PyPlot.pywrap(PyPlot.pyimport("matplotlib.colorbar"))
|
# @eval const pycolorbar = PyPlot.pywrap(PyPlot.pyimport("matplotlib.colorbar"))
|
||||||
if !isa(Base.Multimedia.displays[end], Base.REPL.REPLDisplay)
|
if !isa(Base.Multimedia.displays[end], Base.REPL.REPLDisplay)
|
||||||
PyPlot.ioff() # stops wierd behavior of displaying incomplete graphs in IJulia
|
PyPlot.ioff() # stops wierd behavior of displaying incomplete graphs in IJulia
|
||||||
|
|
||||||
# # TODO: how the hell can I use PyQt4??
|
# # TODO: how the hell can I use PyQt4??
|
||||||
# "pyqt4"=>:qt_pyqt4
|
# "pyqt4"=>:qt_pyqt4
|
||||||
# PyPlot.backend[1] = "pyqt4"
|
# PyPlot.backend[1] = "pyqt4"
|
||||||
@ -243,6 +249,15 @@ function backend()
|
|||||||
rethrow(err)
|
rethrow(err)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
elseif currentBackendSymbol == :glvisualize
|
||||||
|
try
|
||||||
|
@eval import GLVisualize
|
||||||
|
@eval export GLVisualize
|
||||||
|
catch err
|
||||||
|
warn("Couldn't setup GLVisualize")
|
||||||
|
rethrow(err)
|
||||||
|
end
|
||||||
|
|
||||||
elseif currentBackendSymbol == :winston
|
elseif currentBackendSymbol == :winston
|
||||||
warn("Winston support is deprecated and broken. Try another backend: $BACKENDS")
|
warn("Winston support is deprecated and broken. Try another backend: $BACKENDS")
|
||||||
try
|
try
|
||||||
@ -272,7 +287,7 @@ function backend(pkg::PlottingPackage)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function backend(modname)
|
function backend(modname)
|
||||||
|
|
||||||
# set the PlottingPackage
|
# set the PlottingPackage
|
||||||
if modname == :qwt
|
if modname == :qwt
|
||||||
CURRENT_BACKEND.pkg = QwtPackage()
|
CURRENT_BACKEND.pkg = QwtPackage()
|
||||||
@ -290,6 +305,8 @@ function backend(modname)
|
|||||||
CURRENT_BACKEND.pkg = BokehPackage()
|
CURRENT_BACKEND.pkg = BokehPackage()
|
||||||
elseif modname == :plotly
|
elseif modname == :plotly
|
||||||
CURRENT_BACKEND.pkg = PlotlyPackage()
|
CURRENT_BACKEND.pkg = PlotlyPackage()
|
||||||
|
elseif modname == :glvisualize
|
||||||
|
CURRENT_BACKEND.pkg = GLVisualizePackage()
|
||||||
else
|
else
|
||||||
error("Unknown backend $modname. Choose from: $BACKENDS")
|
error("Unknown backend $modname. Choose from: $BACKENDS")
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user