moved series_annotations into series recipe processing; change pyplot clf to fig clear

This commit is contained in:
Thomas Breloff 2016-06-16 00:48:35 -04:00
parent e5c4f782a5
commit ec826fc8ce
2 changed files with 26 additions and 16 deletions

View File

@ -343,7 +343,7 @@ function _create_backend_figure(plt::Plot{PyPlotBackend})
end
# clear the figure
PyPlot.clf()
# PyPlot.clf()
fig
end
@ -1003,12 +1003,10 @@ end
function _before_layout_calcs(plt::Plot{PyPlotBackend})
# clear the figure
PyPlot.clf()
# update the specs
# update the fig
w, h = plt[:size]
fig = plt.o
fig[:clear]()
fig[:set_size_inches](px2inch(w), px2inch(h), forward = true)
fig[:set_facecolor](py_color(plt[:background_color_outside]))
fig[:set_dpi](DPI)

View File

@ -188,6 +188,18 @@ function _apply_series_recipe(plt::Plot, d::KW)
sp.attr[:init] = true
end
# strip out series annotations (those which are based on series x/y coords)
# and add them to the subplot attr
sp_anns = annotations(sp[:annotations])
anns = annotations(pop!(d, :series_annotations, []))
if length(anns) > 0
x, y = d[:x], d[:y]
nx, ny, na = map(length, (x,y,anns))
n = max(nx, ny, na)
anns = [(x[mod1(i,nx)], y[mod1(i,ny)], text(anns[mod1(i,na)])) for i=1:n]
end
sp.attr[:annotations] = vcat(sp_anns, anns)
# adjust extrema and discrete info
if st == :image
w, h = size(d[:z])
@ -454,17 +466,17 @@ function _plot!(plt::Plot, d::KW, args...)
sp = kw[:subplot]
idx = get_subplot_index(plt, sp)
# strip out series annotations (those which are based on series x/y coords)
# and add them to the subplot attr
sp_anns = annotations(sp[:annotations])
anns = annotations(pop!(kw, :series_annotations, []))
if length(anns) > 0
x, y = kw[:x], kw[:y]
nx, ny, na = map(length, (x,y,anns))
n = max(nx, ny, na)
anns = [(x[mod1(i,nx)], y[mod1(i,ny)], text(anns[mod1(i,na)])) for i=1:n]
end
sp.attr[:annotations] = vcat(sp_anns, anns)
# # strip out series annotations (those which are based on series x/y coords)
# # and add them to the subplot attr
# sp_anns = annotations(sp[:annotations])
# anns = annotations(pop!(kw, :series_annotations, []))
# if length(anns) > 0
# x, y = kw[:x], kw[:y]
# nx, ny, na = map(length, (x,y,anns))
# n = max(nx, ny, na)
# anns = [(x[mod1(i,nx)], y[mod1(i,ny)], text(anns[mod1(i,na)])) for i=1:n]
# end
# sp.attr[:annotations] = vcat(sp_anns, anns)
# we update subplot args in case something like the color palatte is part of the recipe
_update_subplot_args(plt, sp, kw, idx)