## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ 3-dim coordinate system plot with objects as elements.

Information and discussion about graphics, figures & tables in LaTeX documents.
zimbodel
Posts: 6
Joined: Tue Jul 31, 2018 4:05 am

### 3-dim coordinate system plot with objects as elements.

The usual cartesian coordinate system obviously has the number system ordered on the axis.
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
3-dimensional-cartesian-axis-system.tex

Stefan Kottwitz
Posts: 9387
Joined: Mon Mar 10, 2008 9:44 pm
You can use symbolic coordinates:

\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}

Stefan

zimbodel
Posts: 6
Joined: Tue Jul 31, 2018 4:05 am
Stefan,
Thank you very much !

That works for me.
Dont know why I couldnt manage to figure it out from the manual.

zimbodel
Posts: 6
Joined: Tue Jul 31, 2018 4:05 am
So now to the second part of the question.
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!

zimbodel
Posts: 6
Joined: Tue Jul 31, 2018 4:05 am
I solved it on my own. Couldnt find it explicitly in the manual, but fiddled around with the code intuitively (which is the wrong way! as you learn nothing.)

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