From 1a751c7baec0640ba56cc9f2cac4ba7da4e4d8b3 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Tue, 19 Nov 2019 14:47:54 +0100 Subject: [PATCH] reproduce 3D docs plot --- src/backends/pgfplotsx.jl | 23 +++++++++-------------- test/test_pgfplotsx.jl | 2 +- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/backends/pgfplotsx.jl b/src/backends/pgfplotsx.jl index 8fd07e4f..422e1c27 100644 --- a/src/backends/pgfplotsx.jl +++ b/src/backends/pgfplotsx.jl @@ -1,3 +1,5 @@ +PGFPlotsX.print_tex(io::IO, data::Symbol) = PGFPlotsX.print_tex(io, string(data)) + const _pgfplotsx_linestyles = KW( :solid => "solid", :dash => "dashed", @@ -445,10 +447,6 @@ function _update_plot_object(plt::Plot{PGFPlotsXBackend}) empty!(PGFPlotsX.CUSTOM_PREAMBLE) for sp in plt.subplots bb = bbox(sp) - legpos = sp[:legend] - if haskey(_pgfplotsx_legend_pos, legpos) - legpos = _pgfplotsx_legend_pos[legpos] - end cstr = plot_color(sp[:background_color_legend]) a = alpha(cstr) title_cstr = plot_color(sp[:titlefontcolor]) @@ -464,7 +462,7 @@ function _update_plot_object(plt::Plot{PGFPlotsXBackend}) "draw opacity" => title_a, "rotate" => sp[:titlefontrotation] ), - "legend pos" => _pgfplotsx_legend_pos[sp[:legend]], + "legend pos" => get(_pgfplotsx_legend_pos, sp[:legend], "outer north east"), "legend style" => PGFPlotsX.Options( pgfx_linestyle(pgfx_thickness_scaling(sp), sp[:foreground_color_legend], 1.0, "solid") => nothing, "fill" => cstr, @@ -492,7 +490,6 @@ function _update_plot_object(plt::Plot{PGFPlotsXBackend}) for series in series_list(sp) for col in (:markercolor, :fillcolor, :linecolor) if typeof(series.plotattributes[col]) == ColorGradient - # TODO: fix this if !pushed_colormap push!(PGFPlotsX.CUSTOM_PREAMBLE, """\\pgfplotsset{ colormap={plots}{$(pgfx_colormap(series.plotattributes[col]))}, @@ -504,12 +501,6 @@ function _update_plot_object(plt::Plot{PGFPlotsXBackend}) ) end - # TODO: is this needed? - # if sp[:colorbar] == :none - # kw[:colorbar] = "false" - # else - # kw[:colorbar] = "true" - # end # goto is needed to break out of col and series for @goto colorbar_end end @@ -543,8 +534,12 @@ function _update_plot_object(plt::Plot{PGFPlotsXBackend}) opt[:x], opt[:y] end series_opt = PGFPlotsX.Options( - "color" => opt[:linecolor] + "color" => opt[:linecolor], + "scatter" => nothing, ) + if opt[:marker_z] !== nothing + push!(series_opt, "point meta" => "explicit") + end segments = iter_segments(series) segment_opt = PGFPlotsX.Options() for (i, rng) in enumerate(segments) @@ -573,7 +568,7 @@ function _update_plot_object(plt::Plot{PGFPlotsXBackend}) end series_plot = series_func( merge(series_opt, segment_opt), - PGFPlotsX.Coordinates(args...) + PGFPlotsX.Coordinates(args..., meta = opt[:marker_z]) ) # add series annotations anns = series[:series_annotations] diff --git a/test/test_pgfplotsx.jl b/test/test_pgfplotsx.jl index 4ee29dbd..12e3ae0e 100644 --- a/test/test_pgfplotsx.jl +++ b/test/test_pgfplotsx.jl @@ -23,7 +23,7 @@ end z = 1:n pl = plot(x, y, z, zcolor=reverse(z), m=(10, 0.8, :blues, Plots.stroke(0)), leg=false, cbar=true, w=5) pgfx_plot, pgfx_tex = create_plot!(pl, zeros(n), zeros(n), 1:n, w=10) - if @test_nowarn(haskey(pgfx_plot.o.contents[1].options.dict, "colormap") == true) + if @test_nowarn(haskey(pgfx_plot.o.contents[1].options.dict, "colorbar") == true) @test pgfx_plot.o.contents[1]["colorbar"] === nothing end end # testset