我有一个分段函数的图表,其中轴上有刻度标记的标签。我为环境使用了以下选项,axis
以便标签不会干扰图表。(我希望标签出现在前景中。)
axis on top
ticklabel style={font=\tiny, circle, fill=white, inner sep=0pt}
这似乎inner sep=0pt
使得两个轴上的标签都太靠近轴。如何保留刻度标记标签和轴之间距离的默认设置?
\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}