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...,
|
||||
getGadflyLineTheme(d))
|
||||
kwargs = Dict()
|
||||
lt = d[:linetype]
|
||||
|
||||
# add a fill?
|
||||
if d[:fillrange] != nothing
|
||||
if d[:fillrange] != nothing && lt != :contour
|
||||
fillmin, fillmax = map(makevec, maketuple(d[:fillrange]))
|
||||
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])]
|
||||
@ -87,7 +88,6 @@ function addGadflyLine!(plt::Plot, d::Dict, geoms...)
|
||||
end
|
||||
|
||||
# h/vlines
|
||||
lt = d[:linetype]
|
||||
if lt == :hline
|
||||
kwargs[:yintercept] = d[:y]
|
||||
elseif lt == :vline
|
||||
@ -97,6 +97,7 @@ function addGadflyLine!(plt::Plot, d::Dict, geoms...)
|
||||
kwargs[:xmin] = d[:x] - w
|
||||
kwargs[:xmax] = d[:x] + w
|
||||
elseif lt == :contour
|
||||
d[:y] = reverse(d[:y])
|
||||
kwargs[:z] = d[:surface]
|
||||
end
|
||||
|
||||
@ -176,7 +177,7 @@ function addToGadflyLegend(plt::Plot, d::Dict)
|
||||
|
||||
# extend the label if we found this color
|
||||
for i in 1:length(guide.colors)
|
||||
if c == guide.colors[i]
|
||||
if RGB(c) == guide.colors[i]
|
||||
guide.labels[i] *= ", " * d[:label]
|
||||
foundit = true
|
||||
end
|
||||
|
||||
@ -257,9 +257,9 @@ function plot!(pkg::PyPlotPackage, plt::Plot; kw...)
|
||||
d[:serieshandle] = if lt == :hist
|
||||
plotfunc(d[:y]; extra_kwargs...)[1]
|
||||
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
|
||||
x, y = d[:y], d[:x]
|
||||
x, y = reverse(d[:y]), d[:x]
|
||||
surf = d[:surface]'
|
||||
handle = plotfunc(x, y, surf, d[:nlevels]; extra_kwargs...)
|
||||
if d[:fillrange] != nothing
|
||||
|
||||
@ -139,6 +139,11 @@ function updatePlotItems(plt::Plot{QwtPackage}, d::Dict)
|
||||
updateLimsAndTicks(plt, d, false)
|
||||
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
|
||||
Qwt.refresh(plt.o)
|
||||
end
|
||||
iargs = getinitargs(subplt,1)
|
||||
# iargs = subplt.initargs
|
||||
Qwt.resizewidget(subplt.o, iargs[:size]...)
|
||||
Qwt.movewidget(subplt.o, iargs[:pos]...)
|
||||
# iargs = getinitargs(subplt,1)
|
||||
# # iargs = subplt.initargs
|
||||
# Qwt.resizewidget(subplt.o, iargs[:size]...)
|
||||
# Qwt.movewidget(subplt.o, iargs[:pos]...)
|
||||
Qwt.showwidget(subplt.o)
|
||||
end
|
||||
|
||||
|
||||
@ -121,10 +121,13 @@ function plot!(plt::Plot, args...; kw...)
|
||||
|
||||
# add title, axis labels, ticks, etc
|
||||
if !haskey(d, :subplot)
|
||||
d = merge!(plt.initargs, d)
|
||||
dumpdict(d, "Updating plot items")
|
||||
updatePlotItems(plt, d)
|
||||
merge!(plt.initargs, d)
|
||||
dumpdict(plt.initargs, "Updating plot items")
|
||||
updatePlotItems(plt, plt.initargs)
|
||||
end
|
||||
|
||||
updatePositionAndSize(plt, d)
|
||||
|
||||
current(plt)
|
||||
|
||||
# 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)
|
||||
# winston() = backend(:winston)
|
||||
|
||||
const _backendNames = Dict(
|
||||
GadflyPackage() => :gadfly,
|
||||
ImmersePackage() => :immerse,
|
||||
PyPlotPackage() => :pyplot,
|
||||
QwtPackage() => :qwt,
|
||||
UnicodePlotsPackage() => :unicodeplots,
|
||||
)
|
||||
backend_name(::GadflyPackage) = :gadfly
|
||||
backend_name(::ImmersePackage) = :immerse
|
||||
backend_name(::PyPlotPackage) = :pyplot
|
||||
backend_name(::UnicodePlotsPackage) = :unicodeplots
|
||||
backend_name(::QwtPackage) = :qwt
|
||||
|
||||
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")
|
||||
# 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, subplt::Subplot; kw...) = error("subplot!($pkg, subplt; kw...) 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
|
||||
"""
|
||||
function backend(pkg::PlottingPackage)
|
||||
CURRENT_BACKEND.sym = _backendNames(pkg)
|
||||
|
||||
CURRENT_BACKEND.sym = backend_name(pkg)
|
||||
CURRENT_BACKEND.pkg = pkg
|
||||
end
|
||||
|
||||
|
||||
@ -289,6 +289,8 @@ function postprocessSubplot(subplt::Subplot, d::Dict)
|
||||
updatePlotItems(plt, di)
|
||||
end
|
||||
|
||||
updatePositionAndSize(subplt, d)
|
||||
|
||||
# handle links
|
||||
subplt.linkx && linkAxis(subplt, true)
|
||||
subplt.linky && linkAxis(subplt, false)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user