diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 92831fca..81f022bd 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -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) diff --git a/src/plot.jl b/src/plot.jl index d5cf7b6b..e1bcb174 100644 --- a/src/plot.jl +++ b/src/plot.jl @@ -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)