Legend for a plot3d

Hello folks,
I’m plotting simple fixed-size cubes, each class on a file with a different color (as in the fig below), overlayed with a 3D surface with high transparency, and adding label="whatever" to each plot3d.
When adding fig.legend() I get this error message. Legend in 2D works but it seems to me that in 3D it doesn’t. Or am I doing something wrong? I haven’t seen any examples of 3D with legend in the tutorials.

Captura de tela 2022-07-17 095813

legend calls plot for symbols so a 3-D cube symbol via plot has not been implemented. So you are not doing anything wrong, it just is not available yet. Since the legend itself is a 2-D feature it is not simple to call plot3d to place that item in the legend. Maybe a perspective custom symbol cube could be used somehow. Need to ponder this issue. Please open a feature request on the GMT core repository.

Thanks for the fast reply.
In the meantime what I did (in case anyone needs this) was create a small side basemap with xshift/yshift and region=[0,1,0,1,0,1], re-plot the cubes, and with a flat 2D basemap, writing the legend. The result was like this:
Captura de tela 2022-07-17 120114

(works, but takes a little more work).

1 Like