LaTeX forum ⇒ Graphics, Figures & Tables3-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.

Postby zimbodel » Sun Aug 05, 2018 12:48 am

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
(1.6 KiB) Downloaded 8 times
3-dimensional-cartesian-axis-system.tex
(1.23 KiB) Downloaded 7 times

User avatar
Stefan Kottwitz
Site Admin
Posts: 8979
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Sun Aug 05, 2018 10:45 am

You can use symbolic coordinates:

  1. \documentclass[border=2mm]{standalone}
  2. \usepackage{pgfplots}
  3. \pgfplotsset{compat=1.8}
  4. \begin{document}
  5. \begin{tikzpicture}
  6. \begin{axis}[
  7. axis lines=center,
  8. xlabel={$x$-axis},ylabel={$y$-axis},zlabel={$z$-axis},
  9. symbolic y coords={nada,apple,orange,DarthVader,Melon,Papaya,Yoda},
  10. ytick = data,
  11. ]
  12. \addplot3 [only marks] coordinates
  13. { (-2,DarthVader,2) (3,Yoda,5)
  14. (1,Papaya,-2) (5,Melon,1)};
  15. \end{axis}
  16. \end{tikzpicture}
  17. \end{document}


Stefan
Site admin

zimbodel
Posts: 6
Joined: Tue Jul 31, 2018 4:05 am

Postby zimbodel » Sun Aug 05, 2018 7:10 pm

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

Postby zimbodel » Sun Aug 05, 2018 8:51 pm

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

Postby zimbodel » Sun Aug 05, 2018 10:07 pm

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.

User avatar
Stefan Kottwitz
Site Admin
Posts: 8979
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Sun Aug 05, 2018 11:06 pm

Great to see that it's solved! Feel free to post the complete code of the plot once you polished it. ;-) I like good diagrams and plots (such as on http://pgfplots.net/).

Stefan
Site admin


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 10 guests