Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am using Pgfplots to make a very simple graph. I already have the code below

\documentclass{article}
\usepackage{tikz,pgfplots}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[>=latex]
\begin{axis}[
  axis x line=center,
  axis y line=center,
  xtick={-5,-4,...,5},
  ytick={-5,-4,...,5},
  xlabel={$x$},
  ylabel={$y$},
  xlabel style={below right},
  ylabel style={above left},
  xmin=-10.5,
  xmax=10.5,
  ymin=-10.5,
  ymax=10.5]
\addplot [mark=none,domain=-4:4] {x};
\end{axis}
\end{tikzpicture}
\end{document}

What I need is to be able to use symbols other than numbers in the axes. So, instead of 1 2 3 4... I would like to have, for instance, + + _ _ + + or other symbols for each point in the axes. How can I do that? I hope my question is clear!

share|improve this question
2  
Do you mean something like xticklabels={$-$, $-$, $-$, $-$, $-$, $+$, $+$, $+$, $+$, $+$, $+$}? –  Jake Feb 7 '13 at 13:43
1  
Yes, I meant that. I used that but then I got only 4 points in the x axis. Then I added your suggestion after xtick={-5,-4,...,5}, and it worked. Do you know how to add those same symbols to the diagonal axis? –  KleinePrins Feb 7 '13 at 13:55
1  
Welcome to TeX.SX. –  Claudio Fiandrino Feb 7 '13 at 13:57
    
@Eduardo.D: With "diagonal axis", do you mean the plot you added using \addplot ...? –  Jake Feb 7 '13 at 13:58
1  
If you want to do a 3D plot, use \addplot3 and take a look at Section 4.5 of the pgfplots manual. –  Psirus Feb 7 '13 at 14:24
show 2 more comments

1 Answer 1

up vote 3 down vote accepted

Maybe you'd be better served with a "real" 3D axis. Here's a small example that shows how to create one (the key point is that you need an \addplot3 command with at least one coordinate:

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    scale=1.5,
    x={(1,0)}, y={(0.6,0.4)}, z={(0,1)},
    axis lines=middle, 
    axis equal image,
    xmin=-4.5, xmax=4.5,
    ymin=-4.5, ymax=4.5,
    zmin=-4.5, zmax=4.5,
    xtick={-5,...,5}, xticklabels={$-$, $-$, $-$, $-$, $-$,, $+$, $+$, $+$, $+$, $+$, $+$},
    ytick={-5,...,5}, yticklabels={$-$, $-$, $-$, $-$, $-$,, $+$, $+$, $+$, $+$, $+$, $+$},
    ztick={-5,...,5}, zticklabels={$-$, $-$, $-$, $-$, $-$,, $+$, $+$, $+$, $+$, $+$, $+$},
    xticklabel style={anchor=north},
    yticklabel style={anchor=north west, inner sep=1pt},
    zticklabel style={anchor=east},
]
\addplot3  [draw=none] coordinates {(0,0,0)};
\end{axis}
\end{tikzpicture}
\end{document}

share|improve this answer
    
This is exactly what I had in mind! Thanks a lot Jake! Also thanks to @Psirus. I am a newbie but I will try to learn something from that long manual. –  KleinePrins Feb 7 '13 at 14:44
    
@Eduardo.D: You're welcome, I'm glad it helps. If you consider this question answered, you can mark it as such by clicking the tick mark next to the answer and upvoting it by clicking the upward-pointing triangle. –  Jake Feb 7 '13 at 14:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.