use TikzDocument and its preamble

This commit is contained in:
Simon Christ 2019-11-19 16:30:53 +01:00
parent 3c9a7193fd
commit 10e7cb8eba

View File

@ -436,15 +436,20 @@ function pgfx_axis!(opt::PGFPlotsX.Options, sp::Subplot, letter)
end end
# -------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
# display calls this and then _display, its called 3 times for plot(1:5) # display calls this and then _display, its called 3 times for plot(1:5)
function _series_updated(plt::Plot{PGFPlotsXBackend}, series::Series) function _create_backend_figure(plt::Plot{PGFPlotsXBackend})
# TODO: don't rebuild plots so often
end end
function _series_updated(plt::Plot{PGFPlotsXBackend}, series::Series)
end
# TODO: don't rebuild plots so often
# IDEA: use functor to only build plot once
function _update_plot_object(plt::Plot{PGFPlotsXBackend}) function _update_plot_object(plt::Plot{PGFPlotsXBackend})
plt.o = PGFPlotsX.GroupPlot() plt.o = PGFPlotsX.TikzDocument()
push!(plt.o, PGFPlotsX.TikzPicture(PGFPlotsX.GroupPlot()))
pushed_colormap = false pushed_colormap = false
empty!(PGFPlotsX.CUSTOM_PREAMBLE)
for sp in plt.subplots for sp in plt.subplots
bb = bbox(sp) bb = bbox(sp)
cstr = plot_color(sp[:background_color_legend]) cstr = plot_color(sp[:background_color_legend])
@ -491,7 +496,7 @@ function _update_plot_object(plt::Plot{PGFPlotsXBackend})
for col in (:markercolor, :fillcolor, :linecolor) for col in (:markercolor, :fillcolor, :linecolor)
if typeof(series.plotattributes[col]) == ColorGradient if typeof(series.plotattributes[col]) == ColorGradient
if !pushed_colormap if !pushed_colormap
push!(PGFPlotsX.CUSTOM_PREAMBLE, """\\pgfplotsset{ PGFPlotsX.push_preamble!(plt.o, """\\pgfplotsset{
colormap={plots}{$(pgfx_colormap(series.plotattributes[col]))}, colormap={plots}{$(pgfx_colormap(series.plotattributes[col]))},
}""") }""")
pushed_colormap = true pushed_colormap = true
@ -587,7 +592,7 @@ function _update_plot_object(plt::Plot{PGFPlotsXBackend})
) )
end end
end end
push!( plt.o, axis ) push!( plt.o.elements[1].elements[1], axis )
end end
end end