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 trying to position the yticks to the left and right of the axis, depending on a comparaion to a reference value. Say in the following plot, I want to position the positive ylabels to the left, and the negatives ones to the right of the axis. enter image description here

The code is as follows (and it is token from a previous poste)

\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=-5.5,
  xmax=5.5,
  ymin=-5.5,
  ymax=5.5]

\end{axis}
\end{tikzpicture}
\end{document}
share|improve this question
    
Would such a design not interfere with the ticks on the negative axis and the negative numbers? –  Christian Hupfer Mar 8 at 16:09
    
No, I can iterate. the point is that my plot is in the second and fourth quarters. So I want to move the positve yticks to the right of the y axis, and the positive xticks above the xaxis –  user2536125 Mar 8 at 16:19
    
I am confused: In your question you wanted to shift the positive values to the left (where they usually are) and the negative labels to the right of the axis -- now it is the other way round? –  Christian Hupfer Mar 8 at 16:23

1 Answer 1

up vote 3 down vote accepted

you could use something like this:

\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={0,1,...,5},
  xlabel={$x$},
  ylabel={$y$},
  xlabel style={below right},
  ylabel style={above left},
  xmin=-5.5,
  xmax=5.5,
  ymin=-5.5,
  ymax=5.5,
  extra y ticks={-5,-4,-3,-2,-1},
  extra y tick style={yticklabel style={xshift=0.5ex, anchor=west}}
  ]
\end{axis}
\end{tikzpicture}
\end{document}

however, as commented above, the tick labels will interefere

share|improve this answer
    
Thnaks, That was exactly what I was looking for –  user2536125 Mar 8 at 16:39

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.