1

I would like to draw some text behind a Poly3DCollection object, unfortunately using the zorder keyword doesn't seem to produce the effect requested.

from mpl_toolkits.mplot3d import Axes3D
from mpl_toolkits.mplot3d.art3d import Poly3DCollection
from matplotlib.pyplot import figure, show

canvas = figure()
axes = Axes3D(canvas)
axes.text(0.5, 0.5, 0.5, 'I would like to be behind!', 'x', zorder=0)

x = [0, 1, 1, 0]
y = [0, 0, 0.5, 0.5]
z = [0, 0, 1, 1]
axes.add_collection3d(Poly3DCollection([zip(x, y, z)], zorder=1))
show()

Matplotlib - Poly3DCollection - Text

Kel Solaar
  • 3,660
  • 1
  • 23
  • 29
  • 3
    This is a limitation of the 3D rendering in mpl. See https://stackoverflow.com/questions/14824893/how-to-draw-diagrams-like-this/14825951#14825951 for a much longer explanation. Axes3D ignores zorder and draws artists in the order it thinks they should be. – tacaswell May 11 '15 at 13:06
  • Cheers, unfortunately it is what I was thinking. – Kel Solaar May 11 '15 at 16:15

0 Answers0