以下代码呈现坐标轴和网格。我只想要一个修改。在 的节点中-10
,我希望忽略减号占据的水平空间。因此, 应该-10
以垂直线为中心,就像10
以垂直线为中心一样。我尝试使用以下命令。
\node[anchor=north, inner sep=0] at ($(-4,0) +(0,-0.1)$){$\makebox[0pt]{$\scriptstyle{-}$}\scriptstyle{10}$};
它没有给我减号和之间的适当间距10
。
\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,intersections,quotes,decorations.markings,decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
%Vertical grid lines are drawn between the vertical lines x=-10 and x=10. (0.4cm represents 1 unit.)
%Since labels for tick marks at (-4,0), (-2,0), (2,0), and (4,0) are typeset, grid lines through these
%points are interrupted.
\draw[draw=gray] ($(-4,-4) +(0,-5pt)$) -- (-4,-0.35);
\draw[draw=gray] (-4,0) -- ($(-4,4) +(0,5pt)$);
\draw[line width=0.1pt, draw=gray!20] ($(-3.6,-4) +(0,-5pt)$) -- ($(-3.6,4) +(0,5pt)$);
\draw[line width=0.1pt, draw=gray!20] ($(-3.2,-4) +(0,-5pt)$) -- ($(-3.2,4) +(0,5pt)$);
\draw[line width=0.1pt, draw=gray!20] ($(-2.8,-4) +(0,-5pt)$) -- ($(-2.8,4) +(0,5pt)$);
\draw[line width=0.1pt, draw=gray!20] ($(-2.4,-4) +(0,-5pt)$) -- ($(-2.4,4) +(0,5pt)$);
\draw[draw=gray] ($(-2,-4) +(0,-5pt)$) -- (-2,-0.35);
\draw[draw=gray] (-2,0) -- ($(-2,4) +(0,5pt)$);
\draw[line width=0.1pt, draw=gray!20] ($(-1.6,-4) +(0,-5pt)$) -- ($(-1.6,4) +(0,5pt)$);
\draw[line width=0.1pt, draw=gray!20] ($(-1.2,-4) +(0,-5pt)$) -- ($(-1.2,4) +(0,5pt)$);
\draw[line width=0.1pt, draw=gray!20] ($(-0.8,-4) +(0,-5pt)$) -- ($(-0.8,4) +(0,5pt)$);
\draw[line width=0.1pt, draw=gray!20] ($(-0.4,-4) +(0,-5pt)$) -- ($(-0.4,4) +(0,5pt)$);
\draw[latex-latex] (0,-4.5) -- (0,4.5);
\draw[line width=0.1pt, draw=gray!20] ($(0.4,-4) +(0,-5pt)$) -- ($(0.4,4) +(0,5pt)$);
\draw[line width=0.1pt, draw=gray!20] ($(0.8,-4) +(0,-5pt)$) -- ($(0.8,4) +(0,5pt)$);
\draw[line width=0.1pt, draw=gray!20] ($(1.2,-4) +(0,-5pt)$) -- ($(1.2,4) +(0,5pt)$);
\draw[line width=0.1pt, draw=gray!20] ($(1.6,-4) +(0,-5pt)$) -- ($(1.6,4) +(0,5pt)$);
\draw[draw=gray] ($(2,-4) +(0,-5pt)$) -- (2,-0.35);
\draw[draw=gray] (2,0) -- ($(2,4) +(0,5pt)$);
\draw[line width=0.1pt, draw=gray!20] ($(2.4,-4) +(0,-5pt)$) -- ($(2.4,4) +(0,5pt)$);
\draw[line width=0.1pt, draw=gray!20] ($(2.8,-4) +(0,-5pt)$) -- ($(2.8,4) +(0,5pt)$);
\draw[line width=0.1pt, draw=gray!20] ($(3.2,-4) +(0,-5pt)$) -- ($(3.2,4) +(0,5pt)$);
\draw[line width=0.1pt, draw=gray!20] ($(3.6,-4) +(0,-5pt)$) -- ($(3.6,4) +(0,5pt)$);
\draw[draw=gray] ($(4,-4) +(0,-5pt)$) -- (4,-0.35);
\draw[draw=gray] (4,0) -- ($(4,4) +(0,5pt)$);
%Horizontal grid lines are drawn between y=-10 and y=10. (0.4cm represents 1 unit.)
%Since labels for tick marks at (0,-4), (0,-2), (0,2), and (0,4) are typeset, grid lines through these
%points are interrupted. The horizontal line through A is also interrupted to accommodate
%the label for A.
\draw[draw=gray] ($(-4,-4) +(-5pt,0)$) -- (-0.7,-4);
\draw[draw=gray] (0,-4) -- ($(4,-4) +(5pt,0)$);
\draw[line width=0.1pt, draw=gray!20] ($(-4,-3.6) +(-5pt,0)$) -- ($(4,-3.6) +(5pt,0)$);
\draw[line width=0.1pt, draw=gray!20] ($(-4,-3.2) +(-5pt,0)$) -- ($(4,-3.2) +(5pt,0)$);
\draw[line width=0.1pt, draw=gray!20] ($(-4,-2.8) +(-5pt,0)$) -- ($(4,-2.8) +(5pt,0)$);
\draw[line width=0.1pt, draw=gray!20] ($(-4,-2.4) +(-5pt,0)$) -- ($(4,-2.4) +(5pt,0)$);
\draw[draw=gray] ($(-4,-2) +(-5pt,0)$) -- (-0.6,-2);
\draw[draw=gray] (0,-2) -- ($(4,-2) +(5pt,0)$);
\draw[line width=0.1pt, draw=gray!20] ($(-4,-1.6) +(-5pt,0)$) -- ($(4,-1.6) +(5pt,0)$);
\draw[line width=0.1pt, draw=gray!20] ($(-4,-1.2) +(-5pt,0)$) -- ($(4,-1.2) +(5pt,0)$);
\draw[line width=0.1pt, draw=gray!20] ($(-4,-0.8) +(-5pt,0)$) -- ($(4,-0.8) +(5pt,0)$);
\draw[line width=0.1pt, draw=gray!20] ($(-4,-0.4) +(-5pt,0)$) -- ($(4,-0.4) +(5pt,0)$);
\draw[latex-latex] (-4.5,0) -- (4.5,0);
\draw[line width=0.1pt, draw=gray!20] ($(-4,0.4) +(-5pt,0)$) -- ($(4,0.4) +(5pt,0)$);
\draw[line width=0.1pt, draw=gray!20] ($(-4,0.8) +(-5pt,0)$) -- ($(4,0.8) +(5pt,0)$);
\draw[line width=0.1pt, draw=gray!20] ($(-4,1.2) +(-5pt,0)$) -- ($(4,1.2) +(5pt,0)$);
\draw[line width=0.1pt, draw=gray!20] ($(-4,1.6) +(-5pt,0)$) -- ($(4,1.6) +(5pt,0)$);
\draw[draw=gray] ($(-4,2) +(-5pt,0)$) -- (-0.3,2);
\draw[draw=gray] (0,2) -- ($(4,2) +(5pt,0)$);
\draw[line width=0.1pt, draw=gray!20] ($(-4,2.4) +(-5pt,0)$) -- ($(4,2.4) +(5pt,0)$);
\draw[line width=0.1pt, draw=gray!20] ($(-4,2.8) +(-5pt,0)$) -- ($(4,2.8) +(5pt,0)$);
\draw[line width=0.1pt, draw=gray!20] ($(-4,3.2) +(-5pt,0)$) -- ($(4,3.2) +(5pt,0)$);
\draw[line width=0.1pt, draw=gray!20] ($(-4,3.6) +(-5pt,0)$) -- (-1.6,3.6);
\draw[line width=0.1pt, draw=gray!20] (-1.2,3.6) -- ($(4,3.6) +(5pt,0)$);
\draw[draw=gray] ($(-4,4) +(-5pt,0)$) -- (-0.4,4);
\draw[draw=gray] (0,4) -- ($(4,4) +(5pt,0)$);
%Tick marks indicating a distance that is a multiple of 5 from an axis are typeset.
\node[anchor=east, inner sep=0, font=\footnotesize] at ($(0,4) +(-0.1,0)$){$\scriptstyle{10}$};
\node[anchor=east, inner sep=0, font=\footnotesize] at ($(0,2) +(-0.1,0)$){$\scriptstyle{5}$};
\node[anchor=east, inner sep=0, font=\footnotesize] at ($(0,-2) +(-0.1,0)$){$\scriptstyle{-5}$};
\node[anchor=east, inner sep=0, font=\footnotesize] at ($(0,-4) +(-0.1,0)$){$\scriptstyle{-10}$};
\node[anchor=north, inner sep=0] at ($(-4,0) +(0,-0.1)$){$\makebox[0pt]{$\scriptstyle{-}$}\scriptstyle{10}$};
\node[anchor=north, inner sep=0] at ($(-2,0) +(0,-0.1)$){$\scriptstyle{-5}$};
\node[anchor=north, inner sep=0] at ($(2,0) +(0,-0.1)$){$\scriptstyle{5}$};
\node[anchor=north, inner sep=0] at ($(4,0) +(0,-0.1)$){$\scriptstyle{10}$};
%The labels for three points O, A, and B are typeset. A path is to be drawn through
%them.
\coordinate (O) at (0,0);
\node[anchor=45, fill=white, rectangle, inner sep=0] at ($(O)+(-135:0.15)$){$\scriptstyle{O}$};
\draw[fill] (O) circle (1.5pt);
\coordinate (A) at (-1.2,3.6);
\node[anchor=east, fill=white, rectangle, inner sep=0.15] at ($(A)+(-0.15,0)$){$\scriptstyle{A}$};
\draw[fill] (A) circle (1.5pt);
\coordinate (B) at (2.8,-1.2);
\node[anchor=135, fill=white, rectangle, inner sep=0.15] at ($(B)+(-45:0.15)$){$\scriptstyle{B}$};
\draw[fill] (B) circle (1.5pt);
%These commands are for drawing a path from O to A.
\coordinate (A1) at (-0.4,0);
\coordinate (A2) at (-0.4,1.2);
\coordinate (A3) at (-1.2,1.2);
\draw[line width=1pt] (O) -- (A1) -- (A2) -- (A3) -- (A);
%These commands are for drawing a path from O to B.
\coordinate (B1) at (0.8,0);
\coordinate (B2) at (0.8,-0.8);
\coordinate (B3) at (2,-0.8);
\coordinate (B4) at (2,-1.2);
\coordinate (B) at (2.8,-1.2);
\draw[line width=1pt] (O) -- (B1) -- (B2) -- (B3) -- (B4) -- (B);
\coordinate (P) at (1.6,2.4);
\node[anchor=-135, inner sep=0] at ($(P) +(45:0.15)$){$\scriptstyle{P}$};
\draw[fill] (P) circle (1.5pt);
\coordinate (Q) at (-2.8,-2.8);
\node[anchor=45, inner sep=0] at ($(Q) +(-135:0.15)$){$\scriptstyle{Q}$};
\draw[fill] (Q) circle (1.5pt);
\end{tikzpicture}
\end{document}