![在 pgfplot 中的轴上添加额外的刻度标记](https://linux22.com/image/438957/%E5%9C%A8%20pgfplot%20%E4%B8%AD%E7%9A%84%E8%BD%B4%E4%B8%8A%E6%B7%BB%E5%8A%A0%E9%A2%9D%E5%A4%96%E7%9A%84%E5%88%BB%E5%BA%A6%E6%A0%87%E8%AE%B0.png)
以下代码在笛卡尔平面上绘制一条线。我想做三处修改。
Extra tick marks at -10 and 10 on the x-axis, and 16 and 17 on the y-axis
Extend the grid lines like horizontally and vertically something like "half a unit"
Remove the white space surrounding the labels for the tick marks
关于函数通过刻度线的图形是否有惯例?在本例中,该线绘制在 x 轴上的“-3”刻度线上。
\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\noindent \hspace*{\fill}
\begin{tikzpicture}[scale=1.5]
\begin{axis}[grid style={line width=.1pt, draw=gray!50},major grid style={line width=.5pt,draw=gray!50},
xmin=-11,xmax=11,
ymin=-34/3,ymax=52/3,
xtick={-9,-6,...,9},
ytick={},
grid=both,
minor x tick num={2},
minor y tick num={4},
enlargelimits={abs=0},
ticklabel style={font=\tiny, fill=white},
extra x ticks={-3, -6, -9},
extra x tick labels={$\llap{$-$}3$, $\llap{$-$}6$, $\llap{$-$}9$},
axis lines=middle,
axis line style={latex-latex, shorten >=-7.5pt, shorten <=-7.5pt},
xlabel=\textit{x},ylabel=\textit{y},
xlabel style={at={(ticklabel* cs:1.05)},anchor=north west},
ylabel style={at={(ticklabel* cs:1.05)},anchor=south west}
]
\addplot[samples=2, latex-latex, blue, domain=-10.5:10.5] {4/3*x + 3};
\addplot[samples=2, dashed, latex-latex, domain=-10.5:10.5] {7} node[pos=0.15, anchor=south, font=\footnotesize] {$y=7$};
\draw[fill] (3,7) circle (1.5pt);
\coordinate (A) at (-7,-19/3);
\coordinate (B) at (0,3);
\end{axis}
%A "pin" is drawn between the label for the graph and a point on the graph.
\draw[draw=gray, shorten <=1mm, shorten >=1mm] (A) -- ($(A)!1.5cm!-90:(B)$);
\node[blue, anchor=north west, inner sep=0, font=\footnotesize] at ($(A)!1.5cm!-90:(B)$) {$y=\dfrac{4}{3} \, x + 3$};
\end{tikzpicture}
\hspace{\fill}
\end{document}