Hi all, how do I add labels to the surfaces below? Using label=
as when plotting curves in 2d does not work. There’s very few information on attributes to surface()
and I can’t find a solution anywhere else for this simple issue.
That’s how I created it:
using Plots, LaTeXStrings
surface(0:0.05:4, 0.05:0.1:0.95, uₜᵣᵤₑ, color=:blues)
surface!(0:0.05:4, 0.05:0.1:0.95, uₚₗₒₜ, zlabel=L"$u(t,x_0)$", colorbar=false, camera=(60,30), fillalpha=0.8)
title!(L"Exact and Approximated Surfaces $M=2$")
All I want is a tiny box in the corner indicating what each surface represents. Let me know if I am not following some best practice when it comes to plotting.
Thank you,
This is a nice solution. I like the small tweaks that add spacing to make the layout look cleaner.
1 Like
Thank you for the clever solution! I wonder why label=
does not work as it does when using plot()
. Nonetheless, it worked just fine.
Gabriel
It works if using Plots; pgfplotsx()
backend, but the labels will be outside the plot. I remember seeing an open issue in github on this matter, but cannot find it anymore.
Plots pgfplotsx() code
using LaTeXStrings, Plots; pgfplotsx()
uₜᵣᵤₑ(x,y) = x + 0.5y; uₚₗₒₜ(x,y) = 2x + y
x, y = 0:0.05:4, 0.05:0.1:0.95
surface(x, y, uₜᵣᵤₑ, colormap_name="viridis", camera=(60,30), cb=false,fa=0.8, label=L"x + 0.5y");
surface!(x, y, uₚₗₒₜ, colormap_name="hot", zlabel=L"$u(t,x_0)$", fa=0.8, label=L"2x + y")
title!(L"Exact and Approximated Surfaces $M=2$")
1 Like