jheinen / GR.jl

Plotting for Julia based on GR, a framework for visualisation applications
Other
356 stars 76 forks source link

Points plotted behind a surface appear as if in front #446

Open giancarloantonucci opened 2 years ago

giancarloantonucci commented 2 years ago

As per title. For instance, one of the two points produced with this MWE should appear behind the surface, but it doesn't:

using Plots; gr()
Θ₁ = -π:0.01:π
Θ₂ = -π:0.01:π
X_torus = [(1 + cos(Θ₂ᵢ)) * cos(Θ₁ᵢ) for Θ₁ᵢ in Θ₁, Θ₂ᵢ in Θ₂]
Y_torus = [(1 + cos(Θ₂ᵢ)) * sin(Θ₁ᵢ) for Θ₁ᵢ in Θ₁, Θ₂ᵢ in Θ₂]
Z_torus = [sin(Θ₂ᵢ) for Θ₁ᵢ in Θ₁, Θ₂ᵢ in Θ₂]
surface(X_torus, Y_torus, Z_torus, colorbar = :none, legend = false, xlims = [-2, 2], ylims = [-2, 2], zlims = [-2, 2]);
scatter!([-2,2], [0, 0], [0, 0], ms=5, color=:black)

plot

Using plotlyjs() this issue doesn't happen, so it seems to be a gr() problem. See this discourse page for more details.

jheinen commented 2 years ago

Unfortunately, this functionality (mix 2D scatter and 3D surfaces) is currently not provided for in GR and cannot be implemented without major reimplementations.

giancarloantonucci commented 2 years ago

My original intention was to mix a 2D line (rather than a 2D scatter plot) with a 3D surface. I guess even this functionality, being so closely related to the one above, isn't (and won't) be provided as well?