Graphics, Figures & Tables ⇒ 3-dim coordinate system plot with objects as elements.
3-dim coordinate system plot with objects as elements.
What I want is a general coordinate system where I can have objects in place of the numbers on the axis.
Before everyone ask what I need it for and steer the question into oblivion. This is to plot abstract Group Theory results which are ordered and bound objects with defined fixed abstract intervals.
So to make a really stupid example, I need to plot a coordinate system with instead of {0,1,2,3,4,5,6} etc on the x-axis, must have {nada,apple,orange,DarthVader, Melon,Papaya,Yoda.....etc} on the axis.
I cannot figure out with what I know about pgplots and tikz how to NOT plot even space numbers, but to plot even spaced objects.
What I ask simply is to have {nada,apple,orange,DarthVader, Melon,Papaya,Yoda.....etc} plotted on the x,y or z-axis evenly spaced and not {0,1,2,3,4,5,6}. That's all.
I attach two cartesian coordinate system LaTeX code examples I found online. Use any of the two to suggest how I can achieve the above.
Thanks
- Attachments
-
- 3-dimensional-cartesian-axis-system-1.tex
- (1.6 KiB) Downloaded 198 times
-
- 3-dimensional-cartesian-axis-system.tex
- (1.23 KiB) Downloaded 228 times
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
- Stefan Kottwitz
- Site Admin
- Posts: 10334
- Joined: Mon Mar 10, 2008 9:44 pm
3-dim coordinate system plot with objects as elements.
Code: Select all
\documentclass[border=2mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines=center,
xlabel={$x$-axis},ylabel={$y$-axis},zlabel={$z$-axis},
symbolic y coords={nada,apple,orange,DarthVader,Melon,Papaya,Yoda},
ytick = data,
]
\addplot3 [only marks] coordinates
{ (-2,DarthVader,2) (3,Yoda,5)
(1,Papaya,-2) (5,Melon,1)};
\end{axis}
\end{tikzpicture}
\end{document}
3-dim coordinate system plot with objects as elements.
Thank you very much !
That works for me.
Dont know why I couldnt manage to figure it out from the manual.
3-dim coordinate system plot with objects as elements.
Stefan solved the problem using the pgfplots package using the second example file I posted. (3-dimensional-cartesian-axis-system.tex)
The remainder of the question is how do you do this WITHOUT using the pgfplots package.
That will mean you have to take the second file I attached in my original post which doesnt use pgfplots but tikz exclusively, namely (3-dimensional-cartesian-axis-system-1.tex)
The question now continues using only the packages used in the headers of "3-dimensional-cartesian-axis-system-1.tex"
In particular, using that file which creates a coordinate system without using pgfplots how do I
1) Replace the numbers on the tickmarks with arbitrary words like ( papaya, DarthVader, Melon, or Yoda ) or whatever.
2) I can then use a label \node at (1,1) {Melon}; as an example, to replace the tickmarks. So basically all I need is how to remove the numbers on the axis but keep everything else as-is in "3-dimensional-cartesian-axis-system-1.tex" as attached in original post.
I used LaTeX graphplotting for years but got stumped lately once I do not use number systems on the axis.
I want to eventually move over to tikz exclusively for all graphics. The manual is amazingly nice and a work of art!
3-dim coordinate system plot with objects as elements.
The solution is to change the original section of code below;
\foreach \x in {1,...,4}
{
\draw [tickstyle] (0,0,\x) -- (0,-ticklen,\x) node[below] {$\x$};
\draw [tickstyle] (\x,0,0) -- (\x,-ticklen,0) node[below] {$\x$};
\draw [tickstyle] (0,\x,0) -- (-ticklen,\x,0) node[left] {$\x$};
}
to this;
\foreach \x in {1,...,4}
{
\draw [tickstyle] (0,0,\x) -- (0,-ticklen,\x) node[below] {$$};
\draw [tickstyle] (\x,0,0) -- (\x,-ticklen,0) node[below] {$$};
\draw [tickstyle] (0,\x,0) -- (-ticklen,\x,0) node[left] {$$};
}
the $\x$ tells the compiler to omit the numbering but keep the coordinates.
So all is solved unless someone has an example that removes the need to add the names by means of labels and that they are printed from a list in the code as stefan did in the other example.
Thanks to all who looked and helped.
- Stefan Kottwitz
- Site Admin
- Posts: 10334
- Joined: Mon Mar 10, 2008 9:44 pm
3-dim coordinate system plot with objects as elements.

Stefan