several fixes, plus qwt pos/size
This commit is contained in:
parent
044d23f8a5
commit
e58fb935b0
@ -76,9 +76,10 @@ function addGadflyLine!(plt::Plot, d::Dict, geoms...)
|
|||||||
gfargs = vcat(geoms...,
|
gfargs = vcat(geoms...,
|
||||||
getGadflyLineTheme(d))
|
getGadflyLineTheme(d))
|
||||||
kwargs = Dict()
|
kwargs = Dict()
|
||||||
|
lt = d[:linetype]
|
||||||
|
|
||||||
# add a fill?
|
# add a fill?
|
||||||
if d[:fillrange] != nothing
|
if d[:fillrange] != nothing && lt != :contour
|
||||||
fillmin, fillmax = map(makevec, maketuple(d[:fillrange]))
|
fillmin, fillmax = map(makevec, maketuple(d[:fillrange]))
|
||||||
nmin, nmax = length(fillmin), length(fillmax)
|
nmin, nmax = length(fillmin), length(fillmax)
|
||||||
kwargs[:ymin] = Float64[min(y, fillmin[mod1(i, nmin)], fillmax[mod1(i, nmax)]) for (i,y) in enumerate(d[:y])]
|
kwargs[:ymin] = Float64[min(y, fillmin[mod1(i, nmin)], fillmax[mod1(i, nmax)]) for (i,y) in enumerate(d[:y])]
|
||||||
@ -87,7 +88,6 @@ function addGadflyLine!(plt::Plot, d::Dict, geoms...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# h/vlines
|
# h/vlines
|
||||||
lt = d[:linetype]
|
|
||||||
if lt == :hline
|
if lt == :hline
|
||||||
kwargs[:yintercept] = d[:y]
|
kwargs[:yintercept] = d[:y]
|
||||||
elseif lt == :vline
|
elseif lt == :vline
|
||||||
@ -97,6 +97,7 @@ function addGadflyLine!(plt::Plot, d::Dict, geoms...)
|
|||||||
kwargs[:xmin] = d[:x] - w
|
kwargs[:xmin] = d[:x] - w
|
||||||
kwargs[:xmax] = d[:x] + w
|
kwargs[:xmax] = d[:x] + w
|
||||||
elseif lt == :contour
|
elseif lt == :contour
|
||||||
|
d[:y] = reverse(d[:y])
|
||||||
kwargs[:z] = d[:surface]
|
kwargs[:z] = d[:surface]
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -176,7 +177,7 @@ function addToGadflyLegend(plt::Plot, d::Dict)
|
|||||||
|
|
||||||
# extend the label if we found this color
|
# extend the label if we found this color
|
||||||
for i in 1:length(guide.colors)
|
for i in 1:length(guide.colors)
|
||||||
if c == guide.colors[i]
|
if RGB(c) == guide.colors[i]
|
||||||
guide.labels[i] *= ", " * d[:label]
|
guide.labels[i] *= ", " * d[:label]
|
||||||
foundit = true
|
foundit = true
|
||||||
end
|
end
|
||||||
|
|||||||
@ -257,9 +257,9 @@ function plot!(pkg::PyPlotPackage, plt::Plot; kw...)
|
|||||||
d[:serieshandle] = if lt == :hist
|
d[:serieshandle] = if lt == :hist
|
||||||
plotfunc(d[:y]; extra_kwargs...)[1]
|
plotfunc(d[:y]; extra_kwargs...)[1]
|
||||||
elseif lt == :contour
|
elseif lt == :contour
|
||||||
# NOTE: x/y are backwards in pyplot, so we switch the x and y args,
|
# NOTE: x/y are backwards in pyplot, so we switch the x and y args (also y is reversed),
|
||||||
# and take the transpose of the surface matrix
|
# and take the transpose of the surface matrix
|
||||||
x, y = d[:y], d[:x]
|
x, y = reverse(d[:y]), d[:x]
|
||||||
surf = d[:surface]'
|
surf = d[:surface]'
|
||||||
handle = plotfunc(x, y, surf, d[:nlevels]; extra_kwargs...)
|
handle = plotfunc(x, y, surf, d[:nlevels]; extra_kwargs...)
|
||||||
if d[:fillrange] != nothing
|
if d[:fillrange] != nothing
|
||||||
|
|||||||
@ -139,6 +139,11 @@ function updatePlotItems(plt::Plot{QwtPackage}, d::Dict)
|
|||||||
updateLimsAndTicks(plt, d, false)
|
updateLimsAndTicks(plt, d, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function updatePositionAndSize(plt::PlottingObject{QwtPackage}, d::Dict)
|
||||||
|
haskey(d, :size) && Qwt.resizewidget(plt.o, d[:size]...)
|
||||||
|
haskey(d, :pos) && Qwt.movewidget(plt.o, d[:pos]...)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
@ -266,10 +271,10 @@ function Base.display(::PlotsDisplay, subplt::Subplot{QwtPackage})
|
|||||||
for plt in subplt.plts
|
for plt in subplt.plts
|
||||||
Qwt.refresh(plt.o)
|
Qwt.refresh(plt.o)
|
||||||
end
|
end
|
||||||
iargs = getinitargs(subplt,1)
|
# iargs = getinitargs(subplt,1)
|
||||||
# iargs = subplt.initargs
|
# # iargs = subplt.initargs
|
||||||
Qwt.resizewidget(subplt.o, iargs[:size]...)
|
# Qwt.resizewidget(subplt.o, iargs[:size]...)
|
||||||
Qwt.movewidget(subplt.o, iargs[:pos]...)
|
# Qwt.movewidget(subplt.o, iargs[:pos]...)
|
||||||
Qwt.showwidget(subplt.o)
|
Qwt.showwidget(subplt.o)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -121,10 +121,13 @@ function plot!(plt::Plot, args...; kw...)
|
|||||||
|
|
||||||
# add title, axis labels, ticks, etc
|
# add title, axis labels, ticks, etc
|
||||||
if !haskey(d, :subplot)
|
if !haskey(d, :subplot)
|
||||||
d = merge!(plt.initargs, d)
|
merge!(plt.initargs, d)
|
||||||
dumpdict(d, "Updating plot items")
|
dumpdict(plt.initargs, "Updating plot items")
|
||||||
updatePlotItems(plt, d)
|
updatePlotItems(plt, plt.initargs)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
updatePositionAndSize(plt, d)
|
||||||
|
|
||||||
current(plt)
|
current(plt)
|
||||||
|
|
||||||
# NOTE: lets ignore the show param and effectively use the semicolon at the end of the REPL statement
|
# NOTE: lets ignore the show param and effectively use the semicolon at the end of the REPL statement
|
||||||
|
|||||||
@ -24,13 +24,11 @@ qwt() = backend(:qwt)
|
|||||||
unicodeplots() = backend(:unicodeplots)
|
unicodeplots() = backend(:unicodeplots)
|
||||||
# winston() = backend(:winston)
|
# winston() = backend(:winston)
|
||||||
|
|
||||||
const _backendNames = Dict(
|
backend_name(::GadflyPackage) = :gadfly
|
||||||
GadflyPackage() => :gadfly,
|
backend_name(::ImmersePackage) = :immerse
|
||||||
ImmersePackage() => :immerse,
|
backend_name(::PyPlotPackage) = :pyplot
|
||||||
PyPlotPackage() => :pyplot,
|
backend_name(::UnicodePlotsPackage) = :unicodeplots
|
||||||
QwtPackage() => :qwt,
|
backend_name(::QwtPackage) = :qwt
|
||||||
UnicodePlotsPackage() => :unicodeplots,
|
|
||||||
)
|
|
||||||
|
|
||||||
include("backends/supported.jl")
|
include("backends/supported.jl")
|
||||||
|
|
||||||
@ -50,6 +48,8 @@ plot!(pkg::PlottingPackage, plt::Plot; kw...) = error("plot!($pkg, plt; kw...) i
|
|||||||
updatePlotItems(pkg::PlottingPackage, plt::Plot, d::Dict) = error("updatePlotItems($pkg, plt, d) is not implemented")
|
updatePlotItems(pkg::PlottingPackage, plt::Plot, d::Dict) = error("updatePlotItems($pkg, plt, d) is not implemented")
|
||||||
# Base.display(pkg::PlottingPackage, plt::Plot) = error("display($pkg, plt) is not implemented")
|
# Base.display(pkg::PlottingPackage, plt::Plot) = error("display($pkg, plt) is not implemented")
|
||||||
|
|
||||||
|
updatePositionAndSize{P<:PlottingPackage}(plt::PlottingObject{P}, d::Dict) = nothing #error("updatePositionAndSize(plt,d) is not implemented for $P")
|
||||||
|
|
||||||
subplot(pkg::PlottingPackage; kw...) = error("subplot($pkg; kw...) is not implemented")
|
subplot(pkg::PlottingPackage; kw...) = error("subplot($pkg; kw...) is not implemented")
|
||||||
subplot!(pkg::PlottingPackage, subplt::Subplot; kw...) = error("subplot!($pkg, subplt; kw...) is not implemented")
|
subplot!(pkg::PlottingPackage, subplt::Subplot; kw...) = error("subplot!($pkg, subplt; kw...) is not implemented")
|
||||||
# Base.display(pkg::PlottingPackage, subplt::Subplot) = error("display($pkg, subplt) is not implemented")
|
# Base.display(pkg::PlottingPackage, subplt::Subplot) = error("display($pkg, subplt) is not implemented")
|
||||||
@ -222,7 +222,8 @@ end
|
|||||||
Set the plot backend. Choose from: :qwt, :gadfly, :unicodeplots, :immerse, :pyplot
|
Set the plot backend. Choose from: :qwt, :gadfly, :unicodeplots, :immerse, :pyplot
|
||||||
"""
|
"""
|
||||||
function backend(pkg::PlottingPackage)
|
function backend(pkg::PlottingPackage)
|
||||||
CURRENT_BACKEND.sym = _backendNames(pkg)
|
|
||||||
|
CURRENT_BACKEND.sym = backend_name(pkg)
|
||||||
CURRENT_BACKEND.pkg = pkg
|
CURRENT_BACKEND.pkg = pkg
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -289,6 +289,8 @@ function postprocessSubplot(subplt::Subplot, d::Dict)
|
|||||||
updatePlotItems(plt, di)
|
updatePlotItems(plt, di)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
updatePositionAndSize(subplt, d)
|
||||||
|
|
||||||
# handle links
|
# handle links
|
||||||
subplt.linkx && linkAxis(subplt, true)
|
subplt.linkx && linkAxis(subplt, true)
|
||||||
subplt.linky && linkAxis(subplt, false)
|
subplt.linky && linkAxis(subplt, false)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user