pgfplots 产生拉伸图片

pgfplots 产生拉伸图片

pgfplots 生成的图表似乎被稍微拉伸了,因此没有保留直角。

\documentclass[12pt,parskip=full,a4paper]{scrartcl}
\usepackage[utf8x]{inputenc}
\usepackage{ucs}
\usepackage[ngerman]{babel}
\usepackage{pgfplots}
\begin{document}

\begin {center}
\begin{tikzpicture}
\begin{axis}[ 
  width=1\linewidth,
  axis lines=middle,
  grid,
  ymin=-10,
  ymax=10,
  ytick={-10,...,10},
  xmin=-10,
  xmax=10,
  xtick={-10,...,10},
  xlabel=x,
  ylabel=y
]
\addplot[black,mark=*] coordinates {(-3,-4) (4,1)}
node[pos=0,left] { A (-3,-4) }
node[pos=1,above right] { B (4,1) }
node[circle,draw=none,fill=none,font=\normalsize,midway,above] {\textit AB};
\addplot[black] coordinates {(-3,-4) (4,-4)}
node[draw=none,fill=none,font=\normalsize,midway,below] {\textit a};
\addplot[black] coordinates {(4,-4) (4,1)}
node[draw=none,fill=none,font=\normalsize,midway,right] {\textit b};
\addplot[black] coordinates {(4,-4) (4,-11) (-3,-11) (-3, -4) };
\addplot[black] coordinates {(4,-4) (9,-4) (9,1) (4,1) };
\addplot[black] coordinates {(-3,-4) (-8,3) (-1,8) (4,1) };\end{axis}
\end{tikzpicture}
\end{center}

\end{document}

结果如下:

极输出

你看到弯曲的角度了吗?它们是从哪里来的?

答案1

使用该 axis equal image选项。

在此处输入图片描述

\documentclass[12pt,parskip=full,a4paper]{scrartcl}
\usepackage[utf8x]{inputenc}
\usepackage{ucs}
\usepackage[ngerman]{babel}
\usepackage{pgfplots}
\begin{document}

\begin {center}
\begin{tikzpicture}
\begin{axis}[ 
  width=1\linewidth,
  axis lines=middle,
  grid,
  ymin=-10,
  ymax=10,
  ytick={-10,...,10},
  xmin=-10,
  xmax=10,
  xtick={-10,...,10},
  xlabel=x,
  ylabel=y,
axis equal image,
]
\addplot[black,mark=*] coordinates {(-3,-4) (4,1)}
node[pos=0,left] { A (-3,-4) }
node[pos=1,above right] { B (4,1) }
node[circle,draw=none,fill=none,font=\normalsize,midway,above] {\textit AB};
\addplot[black] coordinates {(-3,-4) (4,-4)}
node[draw=none,fill=none,font=\normalsize,midway,below] {\textit a};
\addplot[black] coordinates {(4,-4) (4,1)}
node[draw=none,fill=none,font=\normalsize,midway,right] {\textit b};
\addplot[black] coordinates {(4,-4) (4,-11) (-3,-11) (-3, -4) };
\addplot[black] coordinates {(4,-4) (9,-4) (9,1) (4,1) };
\addplot[black] coordinates {(-3,-4) (-8,3) (-1,8) (4,1) };\end{axis}
\end{tikzpicture}
\end{center}

\end{document}

相关内容