3

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}
3
  • Would such a design not interfere with the ticks on the negative axis and the negative numbers?
    – user31729
    Mar 8, 2014 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 Mar 8, 2014 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?
    – user31729
    Mar 8, 2014 at 16:23

1 Answer 1

4

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

1
  • Thnaks, That was exactly what I was looking for Mar 8, 2014 at 16:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .