fixes
This commit is contained in:
parent
273996aa91
commit
80e8b5b5e4
@ -107,7 +107,15 @@ function updateAxisColors(ax, fgcolor)
|
||||
ax[:title][:set_color](fgcolor)
|
||||
end
|
||||
|
||||
nop() = nothing
|
||||
# makePyPlotCurrent(plt::Plot) = PyPlot.withfig(nop, plt.o[1])
|
||||
makePyPlotCurrent(plt::Plot) = PyPlot.figure(plt.o[1].o[:number])
|
||||
# makePyPlotCurrent(plt::Plot) = PyPlot.orig_figure(num = plt.o[1].o[:number])
|
||||
|
||||
|
||||
function preparePlotUpdate(plt::Plot{PyPlotPackage})
|
||||
makePyPlotCurrent(plt)
|
||||
end
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
@ -139,7 +147,7 @@ function plot!(pkg::PyPlotPackage, plt::Plot; kw...)
|
||||
|
||||
fig, num = plt.o
|
||||
# PyPlot.figure(num) # makes this current
|
||||
makePyPlotCurrent(plt)
|
||||
# makePyPlotCurrent(plt)
|
||||
|
||||
if !(d[:linetype] in supportedTypes(pkg))
|
||||
error("linetype $(d[:linetype]) is unsupported in PyPlot. Choose from: $(supportedTypes(pkg))")
|
||||
@ -218,7 +226,7 @@ end
|
||||
|
||||
|
||||
function updatePlotItems(plt::Plot{PyPlotPackage}, d::Dict)
|
||||
makePyPlotCurrent(plt)
|
||||
# makePyPlotCurrent(plt)
|
||||
haskey(d, :title) && PyPlot.title(d[:title])
|
||||
haskey(d, :xlabel) && PyPlot.xlabel(d[:xlabel])
|
||||
if haskey(d, :ylabel)
|
||||
@ -266,7 +274,10 @@ end
|
||||
|
||||
function Base.writemime(io::IO, m::MIME"image/png", plt::PlottingObject{PyPlotPackage})
|
||||
fig, num = plt.o
|
||||
# makePyPlotCurrent(plt)
|
||||
addPyPlotLegend(plt)
|
||||
ax = fig.o[:axes][1]
|
||||
updateAxisColors(ax, getPyPlotColor(plt.initargs[:foreground_color]))
|
||||
writemime(io, m, fig)
|
||||
end
|
||||
|
||||
@ -274,7 +285,7 @@ end
|
||||
function Base.display(::PlotsDisplay, plt::Plot{PyPlotPackage})
|
||||
fig, num = plt.o
|
||||
# PyPlot.figure(num) # makes this current
|
||||
makePyPlotCurrent(plt)
|
||||
# makePyPlotCurrent(plt)
|
||||
addPyPlotLegend(plt)
|
||||
ax = fig.o[:axes][1]
|
||||
updateAxisColors(ax, getPyPlotColor(plt.initargs[:foreground_color]))
|
||||
|
||||
@ -87,6 +87,9 @@ function plot!(plt::Plot, args...; kw...)
|
||||
# Ideally we don't change the insides ot createKWargsList too much to
|
||||
# save from code repetition. We could consider adding a throw
|
||||
|
||||
# just in case the backend needs to set up the plot (make it current or something)
|
||||
preparePlotUpdate(plt)
|
||||
|
||||
kwList = createKWargsList(plt, args...; d...)
|
||||
for (i,d) in enumerate(kwList)
|
||||
plt.n += 1
|
||||
@ -105,6 +108,8 @@ function plot!(plt::Plot, args...; kw...)
|
||||
plt
|
||||
end
|
||||
|
||||
preparePlotUpdate(plt::Plot) = nothing
|
||||
|
||||
# # show/update the plot
|
||||
# function Base.display(plt::PlottingObject)
|
||||
# display(plt.plotter, plt)
|
||||
@ -195,7 +200,7 @@ function createKWargsList(plt::PlottingObject, f::FuncOrFuncs; kw...)
|
||||
end
|
||||
|
||||
function createKWargsList(plt::PlottingObject, f::FuncOrFuncs, x; kw...)
|
||||
@assert !(x <: FuncOrFuncs) # otherwise we'd hit infinite recursion here
|
||||
@assert !(typeof(x) <: FuncOrFuncs) # otherwise we'd hit infinite recursion here
|
||||
createKWargsList(plt, x, f; kw...)
|
||||
end
|
||||
|
||||
|
||||
@ -179,6 +179,7 @@ function plotter!(modname)
|
||||
|
||||
# update the symbol
|
||||
CURRENT_BACKEND.sym = modname
|
||||
println("[Plots.jl] Switched to backend: ", modname)
|
||||
|
||||
# return the package
|
||||
CURRENT_BACKEND.pkg
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user