6

I have a graph for a piecewise function with labels for the tick marks on the axes. I used the following options for the axis environment so that the labels do not interfere with the graph. (I want the labels to appear to be in the foreground.)

axis on top
ticklabel style={font=\tiny, circle, fill=white, inner sep=0pt}

It seems that inner sep=0pt makes the labels on both axes too close to the axes. How do I keep the default settings for the distance between the labels for tick marks and the axes?

\documentclass{amsart}
\usepackage{amsmath}

\usepackage{tikz}
\usetikzlibrary{calc,intersections}

\usepackage{pgfplots}
\pgfplotsset{compat=1.11}

\begin{document}

\begin{tikzpicture}
\begin{axis}[height=3.5in, width=3.5in, axis equal image, axis on top, clip=false,
    xmin=-3.5,xmax=4.5,
    ymin=-2.5,ymax=2.5,
    restrict y to domain=-2.5:2.5,
    xtick={-3, -2, -1, 1, 2, 3, 4}, ytick={-2, -1, 1, 2},
    ticklabel style={font=\tiny, circle, fill=white, inner sep=0pt},
    xticklabels={\makebox[0pt][r]{$-$}3, \makebox[0pt][r]{$-$}2, \makebox[0pt][r]{$-$}1, 1, 2, 3, 4},
    yticklabels={-2, -1, , 1, 2},
    yticklabels={-2, -1, 1, 2},
    axis lines=middle,
    axis line style={latex-latex},
    xlabel=$x$,ylabel=$y$,
    axis line style={shorten >=-12.5pt, shorten <=-12.5pt},
    xlabel style={at={(ticklabel* cs:1)}, xshift=12.5pt, anchor=north west},
    ylabel style={at={(ticklabel* cs:1)}, yshift=12.5pt, anchor=south west}
]


\addplot[samples=2, blue, domain=-3:0] {-x - 2};
\addplot[samples=501, blue, domain=0:4] {sqrt(4 - (x - 2)^2) - 2};

\draw[fill=blue] (-3,1) circle [radius=1.5pt];
\draw[fill=blue] (0,-2) circle [radius=1.5pt];
\draw[fill=blue] (4,-2) circle [radius=1.5pt];

\coordinate (A) at (-2.75,0.75);
\coordinate (B) at (-2.25,1.25);

\end{axis}

%A "pin" is drawn between the label for the graph and the point (7, 1/8) on the graph.
\draw[draw=gray, shorten <=1mm, shorten >=1mm] (A) -- (B);
\node[blue, anchor=south west, inner sep=0, font=\scriptsize] at ($(B)$) {$y = f^{\prime}(x)$};

\end{tikzpicture}

\end{document}
7

What you need is to increase outer sep distance

ticklabel style={font=\tiny, circle, fill=white, inner sep=0pt,outer sep=3pt}

enter image description here

  • 2
    Do you know the value that would return the tick labels to their default distances? – A gal named Desire Feb 25 '17 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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