以下代码在笛卡尔平面上绘制一条线。我想做三处修改。
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}