在线图上绘制的轴太长

在线图上绘制的轴太长

我希望轴的绘制12.5pt范围比为两个线性函数指定的“最宽范围”更远。这似乎绘制正确。为什么y- 轴比指定的长得多?最小函数值为-8.5,最大函数值为9y- 轴绘制范围远了一厘米多。

\documentclass{amsart}
\usepackage{mathtools,array}

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


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


\begin{document}

\begin{tikzpicture}
\begin{axis}[width=4in, height=4in, axis equal=true, clip=false,
    axis lines=middle,
    xmin=-10.5,xmax=15,
    ymin=-8.5,ymax=9,
    restrict y to domain=-8.5:9,
    axis line style={latex-latex},
    xlabel=\textit{x},ylabel=\textit{y},
    %xtick={\empty},ytick={\empty},
    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}
]


%The equation for the line through P and Q is y = (-5/2)*x + 3/2, and the equation for the
%line that is perpendicular bisector for PQ is y = (2/5)x - 43/10. The x-intercept and the
%y-intercept for $\ell$ are A=(43/4,0) and B = (0,-43/10).

\addplot[latex-latex, dashed, domain=-10.5:15] {(2/5)*x - 43/10};
\addplot[latex-latex, domain=-3:4] {(-5/2)*x + 3/2};
\coordinate (P) at (2,-3.5);
\draw [fill] (P) circle [radius=1.5pt];


\coordinate (label_for_k) at (4,-8.5);
\coordinate (label_for_ell) at (15,17/10);

\end{axis}


\draw node[anchor={atan(-5/2)+180}, inner sep=0] at ($(label_for_k) +({atan(-5/2)}:0.15)$){\textit{k}};
\draw node[anchor={atan(2/5)+180}, inner sep=0] at ($(label_for_ell) +({atan(2/5)}:0.15)$){$\ell$};


%A "pin" is drawn between the label for the intersection of the two lines and the intersection.
\draw[draw=gray, shorten <=1mm, shorten >=1mm] (P) -- ($(P) +({0.5*(atan(-5/2)+atan(2/5))}:0.75)$);
\node[anchor=north west, inner sep=0, font=\scriptsize] at ($(P) +({0.5*(atan(-5/2)+atan(2/5))}:0.75)$){\makebox[0pt][l]{$\left(2, \, \frac{-7}{2}\right)$}};

\end{tikzpicture}


\end{document}

答案1

通过删除axis equal=true你可以达到所需的长度

\documentclass{amsart}
\usepackage{mathtools,array}

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


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


\begin{document}

\begin{tikzpicture}
\begin{axis}[width=4in, height=4in, clip=false, 
    axis lines=middle,
    xmin=-10.5,xmax=15,
    ymin=-8.5,ymax=9,
    restrict y to domain=-8.5:9,
    axis line style={latex-latex},
    xlabel=\textit{x},ylabel=\textit{y},
    %xtick={\empty},ytick={\empty},
    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}
]


%The equation for the line through P and Q is y = (-5/2)*x + 3/2, and the equation for the
%line that is perpendicular bisector for PQ is y = (2/5)x - 43/10. The x-intercept and the
%y-intercept for $\ell$ are A=(43/4,0) and B = (0,-43/10).

\addplot[latex-latex, dashed, domain=-10.5:15] {(2/5)*x - 43/10};
\addplot[latex-latex, domain=-3:4] {(-5/2)*x + 3/2};
\coordinate (P) at (2,-3.5);
\draw [fill] (P) circle [radius=1.5pt];


\coordinate (label_for_k) at (4,-8.5);
\coordinate (label_for_ell) at (15,17/10);

\end{axis}


\draw node[anchor={atan(-5/2)+180}, inner sep=0] at ($(label_for_k) +({atan(-5/2)}:0.15)$){\textit{k}};
\draw node[anchor={atan(2/5)+180}, inner sep=0] at ($(label_for_ell) +({atan(2/5)}:0.15)$){$\ell$};


%A "pin" is drawn between the label for the intersection of the two lines and the intersection.
\draw[draw=gray, shorten <=1mm, shorten >=1mm] (P) -- ($(P) +({0.5*(atan(-5/2)+atan(2/5))}:0.75)$);
\node[anchor=north west, inner sep=0, font=\scriptsize] at ($(P) +({0.5*(atan(-5/2)+atan(2/5))}:0.75)$){\makebox[0pt][l]{$\left(2, \, \frac{-7}{2}\right)$}};

\end{tikzpicture}


\end{document}

在此处输入图片描述

相关内容