Plots.jl with PGFPlotsX adds series in the wrong order

Joseph_Bradley
Wed, 17 Aug 2022 20:57:25 +0000
Visualization

In Plots.jl, the PGFPlotsX backend won’t let me add another series with proper control over the z-order. Here is the MWE:

using Plots
pgfplotsx()

input = range(0, 4π, 100)
output = cos.(input)

plt = scatter(input, output, label = "data")
plot!(plt, input, output, label = "theory")

This puts the theory series behind the data series, when it should be the other way around:

GR works fine:

gr()

plt = scatter(input, output, label = "data")
plot!(plt, input, output, label = "theory")

Using the z_order attribute makes no difference:

pgfplotsx()
plt = scatter(input, output, label = "data", z_order = 1)
plot!(plt, input, output, label = "theory", z_order = 2)

Does anyone have any suggestions? I am not familiar with the PGF interface at all so I can’t find a way of using PGFPlotsX directly, but would appreciate a pointer.

Many thanks!

3 posts - 2 participants