moved pyplot methods _series_added and _initialize_subplot into the display pipeline

This commit is contained in:
Thomas Breloff 2016-06-14 18:02:44 -04:00
parent f64108523c
commit 3d7d8caa82

View File

@ -347,7 +347,9 @@ function _create_backend_figure(plt::Plot{PyPlotBackend})
end end
# Set up the subplot within the backend object. # Set up the subplot within the backend object.
function _initialize_subplot(plt::Plot{PyPlotBackend}, sp::Subplot{PyPlotBackend}) # function _initialize_subplot(plt::Plot{PyPlotBackend}, sp::Subplot{PyPlotBackend})
function py_init_subplot(plt::Plot{PyPlotBackend}, sp::Subplot{PyPlotBackend})
fig = plt.o fig = plt.o
proj = sp[:projection] proj = sp[:projection]
proj = (proj in (nothing,:none) ? nothing : string(proj)) proj = (proj in (nothing,:none) ? nothing : string(proj))
@ -367,7 +369,9 @@ end
# function _series_added(pkg::PyPlotBackend, plt::Plot, d::KW) # function _series_added(pkg::PyPlotBackend, plt::Plot, d::KW)
# TODO: change this to accept Subplot?? # TODO: change this to accept Subplot??
function _series_added(plt::Plot{PyPlotBackend}, series::Series) # function _series_added(plt::Plot{PyPlotBackend}, series::Series)
function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
d = series.d d = series.d
st = d[:seriestype] st = d[:seriestype]
sp = d[:subplot] sp = d[:subplot]
@ -875,28 +879,28 @@ end
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
function update_limits!(sp::Subplot{PyPlotBackend}, series::Series, letters) # function update_limits!(sp::Subplot{PyPlotBackend}, series::Series, letters)
for letter in letters # for letter in letters
py_set_lims(sp.o, sp[Symbol(letter, :axis)]) # py_set_lims(sp.o, sp[Symbol(letter, :axis)])
end # end
end # end
function _series_updated(plt::Plot{PyPlotBackend}, series::Series) # function _series_updated(plt::Plot{PyPlotBackend}, series::Series)
d = series.d # d = series.d
for handle in d[:serieshandle] # for handle in get(d, :serieshandle, [])
if is3d(series) # if is3d(series)
handle[:set_data](d[:x], d[:y]) # handle[:set_data](d[:x], d[:y])
handle[:set_3d_properties](d[:z]) # handle[:set_3d_properties](d[:z])
else # else
try # try
handle[:set_data](d[:x], d[:y]) # handle[:set_data](d[:x], d[:y])
catch # catch
handle[:set_offsets](hcat(d[:x], d[:y])) # handle[:set_offsets](hcat(d[:x], d[:y]))
end # end
end # end
end # end
update_limits!(d[:subplot], series, is3d(series) ? (:x,:y,:z) : (:x,:y)) # update_limits!(d[:subplot], series, is3d(series) ? (:x,:y,:z) : (:x,:y))
end # end
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
@ -986,6 +990,9 @@ end
function _before_layout_calcs(plt::Plot{PyPlotBackend}) function _before_layout_calcs(plt::Plot{PyPlotBackend})
# clear the figure
PyPlot.clf()
# update the specs # update the specs
w, h = plt[:size] w, h = plt[:size]
fig = plt.o fig = plt.o
@ -996,9 +1003,18 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend})
# resize the window # resize the window
PyPlot.plt[:get_current_fig_manager]()[:resize](w, h) PyPlot.plt[:get_current_fig_manager]()[:resize](w, h)
# initialize subplots
for sp in plt.subplots
py_init_subplot(plt, sp)
end
# add the series
for series in plt.series_list
py_add_series(plt, series)
end
# update subplots # update subplots
for sp in plt.subplots for sp in plt.subplots
# ax = getAxis(sp)
ax = sp.o ax = sp.o
if ax == nothing if ax == nothing
continue continue
@ -1012,16 +1028,16 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend})
# title # title
if sp[:title] != "" if sp[:title] != ""
loc = lowercase(string(sp[:title_location])) loc = lowercase(string(sp[:title_location]))
field = if loc == "left" func = if loc == "left"
:_left_title :_left_title
elseif loc == "right" elseif loc == "right"
:_right_title :_right_title
else else
:title :title
end end
ax[field][:set_text](sp[:title]) ax[func][:set_text](sp[:title])
ax[field][:set_fontsize](sp[:titlefont].pointsize) ax[func][:set_fontsize](sp[:titlefont].pointsize)
ax[field][:set_color](py_color(sp[:foreground_color_title])) ax[func][:set_color](py_color(sp[:foreground_color_title]))
# ax[:set_title](sp[:title], loc = loc) # ax[:set_title](sp[:title], loc = loc)
end end