You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: 3D text does not respect rotation to make it parallel with a given zdir axis #30563
3D text rotated along a given axis, e.g. zdir = "x" or zdir = (1, 0, 0), is always rotated roughly 60 degrees and does not respect the rotation argument for changing the orientation to e.g. 0 or 90 to be parallel with the specified axis.
The rotation parameter is basically ignored in the current codebase.
It only rotates the text about the axis going through the display screen.
I think neither FreeType nor the AGG library has the means to perform 3D rotation (which requires image distortion).
A new function might be required to be built to make this work.
It's a significant undertaking, but AGG's perspective transformation functions can do the trick alongside a custom algorithm that utilizes the project matrix proj variable found in draw_text function.
However I think the current parameters aren't suited for this task. zdir states that it's the text direction (when the name actually implies that it's the new Z-component of the co-ordinate space). rotation on its own is meaningless; it requires an axis. So, perhaps a tuple-based rotation_axis parameter might be needed...?
ifrotationisnotNone:
warnings.showwarning(
"The `rotation` parameter has not yet been implemented ""and is currently ignored.",
UserWarning, 'Matplotlib - MPL Toolkits - MPlot3D', ''
)
...
ifrotation_modeisnotNone:
warnings.showwarning(
"The `rotation_mode` parameter has not yet been implemented ""and is currently ignored.",
UserWarning, 'Matplotlib - MPL Toolkits - MPlot3D', ''
)
I did something like the above, and then I tested this issue's code example. It resulted in way too many warnings flooding in.
Apparently Text3D.__init__ is not called, as shown in my video.
This is because in this issue's example code (called via Axes3D), the Text class is initialized, and not Text3D based on this:
Activity
melwyncarlo commentedon Sep 18, 2025
Similar queries:
The
rotationparameter is basically ignored in the current codebase.It only rotates the text about the axis going through the display screen.
I think neither FreeType nor the AGG library has the means to perform 3D rotation (which requires image distortion).
A new function might be required to be built to make this work.
timhoffm commentedon Sep 19, 2025
Correct. We should document that
rotationandrotation_modeare not supported in https://matplotlib.org/stable/api/_as_gen/mpl_toolkits.mplot3d.axes3d.Axes3D.text.html#mpl_toolkits.mplot3d.axes3d.Axes3D.text. And possibly give a warning when they are used.melwyncarlo commentedon Sep 19, 2025
It's a significant undertaking, but AGG's perspective transformation functions can do the trick alongside a custom algorithm that utilizes the project matrix
projvariable found indraw_textfunction.However I think the current parameters aren't suited for this task.
zdirstates that it's the text direction (when the name actually implies that it's the new Z-component of the co-ordinate space).rotationon its own is meaningless; it requires an axis. So, perhaps a tuple-basedrotation_axisparameter might be needed...?melwyncarlo commentedon Sep 19, 2025
I did something like the above, and then I tested this issue's code example. It resulted in way too many warnings flooding in.
timhoffm commentedon Sep 19, 2025
That’s the wrong place. Put it in
Text3D.__init__melwyncarlo commentedon Sep 25, 2025
Apparently
Text3D.__init__is not called, as shown in my video.This is because in this issue's example code (called via Axes3D), the
Textclass is initialized, and notText3Dbased on this:matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py
Line 1953 in 3796813
and then the Text3D class is assigned to the object, based on this:
matplotlib/lib/mpl_toolkits/mplot3d/art3d.py
Line 222 in 3796813
So, I've placed the warnings in two files:
axes3d.py(for theAxes3D.textfunction) andart3d.py(for theText3Dclass)The results are much better: (4 warnings for two calls to the
Axes3D.textfunction; one forrotationand one forrotation_mode)scottshambaugh commentedon Dec 18, 2025
I reopened #1037 to keep track of this request.