MHB How can I rotate the xyz axis in TikZ using the tdplotsetmaincoords command?

  • Thread starter Thread starter Dustinsfl
  • Start date Start date
AI Thread Summary
The discussion highlights a method to rotate the xyz axis in TikZ using the tdplotsetmaincoords command. It explains that the default positioning of the z-axis can be confusing, as it typically occupies the space of the x-axis in 3D representations. By using the command \tdplotsetmaincoords{72}{120}, users can achieve a more visually appealing orientation without needing to swap coordinates. This approach allows for customization of angles, enhancing the overall presentation of 3D plots. The solution aims to assist users seeking to improve their TikZ graphics.
Dustinsfl
Messages
2,217
Reaction score
5
I am not sure if you all who use tikz are aware of this but here is what I figured out today.

I am sure those of you who use tikz know that when you do (x,y,z) the z axis is where the x-axis usually is in 3D. You could always rename it but then you have to remember to swap coordinates x and z. Additionally, the appearance would be nicer if we could rotate the axis.

[LATEXS]
\tdplotsetmaincoords{72}{120}
\begin{tikzpicture}[line join = round, line cap = round, >=triangle 45, tdplot_main_coords]
[/LATEXS]
This will set the xyz axis in the normal position with a better appearance. This way you don't have to swap the x and z in (x,y,z).
 
Last edited:
Physics news on Phys.org
Also, the angles can be changed to whatever you want.\end{tikzpicture}I hope this helps anyone who was looking for a way to rotate the xyz axis in tikz.
 
Back
Top