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

  • Topic:
  • Thread starter Thread starter Dustinsfl
  • Start date Start date
Join the discussion
Registration is free. Start your own thread to ask a follow-up.
1 reply · 4K views
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.