4

I have asked about moving a tick mark from below the x-axis to above the x-axis. (I used the specification xticklabel shift=-16pt.) In the following graph, the tick mark is at a point where the graph has a horizontal asymptote. I need to move the tick mark 2pt either to the left or to the right.

enter image description here

\documentclass[10pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}


\begin{document}

\begin{tikzpicture}
\begin{axis}[width=6in,axis equal image,unit vector ratio={2 1},clip=false,
    axis lines=middle,
    xmin=-1.5,xmax=2.5,
    domain=-1.5:2.5, samples=201,
    xlabel=$x$,ylabel=$y$,
    ymin=-1,ymax=3,
    restrict y to domain=-1:3,
    enlargelimits={abs=0.5cm},
    axis line style={latex-latex},
    ticklabel style={font=\tiny,fill=white},
    xtick={\empty},ytick={\empty},
    extra x ticks={0.83333, 1, 1.6666},
    extra x tick labels={$\frac{5}{6}$, $1$, $\frac{5}{3}$},
    extra y ticks={-2},
    extra y tick labels={$ma+b$},
    yticklabel style={anchor=west},
    yticklabel shift=-4pt,
    ticklabel style={font=\tiny,fill=white},
    xtick={0.83333, 1, 1.6666},ytick={\empty},
    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
    ylabel style={at={(ticklabel* cs:1)},anchor=south west}
]
\addplot[samples=501,domain=-1.5:1,blue] {-1* x * abs((x - 1))^(1/5)};
\addplot[samples=501,domain=1:4,blue] {x * abs((x - 1))^(1/5)} node[below right,pos=0.75,font=\footnotesize]{$y=f(x)$};
\draw [fill] (0.83333,-0.58236) circle [radius=1.5pt];
\draw [fill] (1,0) circle [radius=1.5pt];
\draw [fill] (1.6666,1.53685) circle [radius=1.5pt];
\end{axis}
\end{tikzpicture}

\end{document}
Peter Grill
  • 223,288
Adelyn
  • 3,373

1 Answers1

3

Since you only want to move one tick mark, it is best to simply tweak it with a bit of a space. So something like

extra x tick labels={$\frac{5}{6}$, \hspace*{0.5em}$1$, $\frac{5}{3}$}

yields:

enter image description here

Code:

\documentclass[10pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}

\begin{document}

\begin{tikzpicture} \begin{axis}[width=6in,axis equal image,unit vector ratio={2 1},clip=false, axis lines=middle, xmin=-1.5,xmax=2.5, domain=-1.5:2.5, samples=201, xlabel=$x$,ylabel=$y$, ymin=-1,ymax=3, restrict y to domain=-1:3, enlargelimits={abs=0.5cm}, axis line style={latex-latex}, ticklabel style={font=\tiny,fill=white}, %xtick={\empty},ytick={\empty}, extra x ticks={0.83333, 1, 1.6666}, extra x tick labels={$\frac{5}{6}$, \hspace{0.5em}$1$, $\frac{5}{3}$}, extra y ticks={-2}, extra y tick labels={$ma+b$}, yticklabel style={anchor=west}, yticklabel shift=-4pt, ticklabel style={font=\tiny,fill=white}, xtick={0.83333, 1, 1.6666},ytick={\empty}, xlabel style={at={(ticklabel cs:1)},anchor=north west}, ylabel style={at={(ticklabel* cs:1)},anchor=south west} ] \addplot[samples=501,domain=-1.5:1,blue] {-1* x * abs((x - 1))^(1/5)}; \addplot[samples=501,domain=1:4,blue] {x * abs((x - 1))^(1/5)} node[below right,pos=0.75,font=\footnotesize]{$y=f(x)$}; \draw [fill] (0.83333,-0.58236) circle [radius=1.5pt]; \draw [fill] (1,0) circle [radius=1.5pt]; \draw [fill] (1.6666,1.53685) circle [radius=1.5pt]; \end{axis} \end{tikzpicture}

\end{document}

Peter Grill
  • 223,288
  • Thanks again. You just put a spacing command from text mode before the label for the tick mark. Do you have to use the *-version of the space command? Did TikZ really move it half the width of "M"? – Adelyn Oct 30 '14 at 16:59
  • The * variant ensures the space is added even at the beginning of the line. I did not test if it works without the *. Yes, the space is intended to be approximately half the width of an m, accounting for the fact that font size of the ticklabel. – Peter Grill Oct 30 '14 at 17:11
  • I have a question that is not relevant to this post. Do you know the length of each side of the right angle mark in this drawing? I have a diagram of right triangles that are drawn using tkz-euclide on another page; I want the right-angle marks that I have to manually make in this diagram to be identical to the right angle marks drawn by TikZ. – Adelyn Dec 07 '14 at 15:43
  • @Adelyn: As that is totally unrelated to this question, please post a new question. That way it will be helpful to a larger audience. – Peter Grill Dec 08 '14 at 05:17
  • I just posted it. "Getting the same angle marks using pgfplots as those using TikZ" – Adelyn Dec 09 '14 at 21:50