是 Graphics 及相关函数的一个选项,用来指定图形宽高比.
AspectRatio
是 Graphics 及相关函数的一个选项,用来指定图形宽高比.
更多信息
- AspectRatio 确定最后图象形状的比例.
- 典型设置包括:
-
Automatic 根据实际坐标值确定比值 Full 拉伸图形填充封闭区域 a 明确的高宽比
范例
打开所有单元 关闭所有单元基本范例 (2)
范围 (2)
Automatic 可用于从实际图形值中选择比值:
{Plot[Sqrt[1 - x ^ 2], {x, 0, 1}], Plot[Sqrt[1 - x ^ 2], {x, 0, 1}, AspectRatio -> Automatic]}{ParametricPlot[{Cos[u], 1 / 10Sin[u]}, {u, 0, 2Pi}],
ParametricPlot[{Cos[u], 1 / 10Sin[u]}, {u, 0, 2Pi}, AspectRatio -> 1 / 2]}推广和延伸 (2)
Table[Framed@Graphics3D[Sphere[], AspectRatio -> 1 / k], {k, 1, 3}]利用 Automatic 的设置保持自然的三维投影:
Table[Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3}, AspectRatio -> ar], {ar, {Automatic, 2}}]属性和关系 (5)
AspectRatio 确定 PlotRange 的比值,而不是 ImageSize:
Framed[Graphics[{Pink, Disk[]}, PlotRange -> {{-1, 1}, {-1, 1}}, Frame -> True, AspectRatio -> 2, ImageSize -> {200, 100}]]Graphics[{Pink, Disk[]}, PlotRange -> {{-2, 2}, {-1, 1}}, Frame -> True]默认情况下,Plot、ListPlot 和 ListLinePlot 使用比值 1/GoldenRatio:
{Plot[Sin[x], {x, 0, 2Pi}], Plot[Sin[x], {x, 0, 2Pi}, AspectRatio -> 1 / GoldenRatio]}某些图形,例如 ParametricPlot 和 ArrayPlot,缺省使用 Automatic:
ParametricPlot[{u Cos[u], u Sin[u] / 2}, {u, 0, 4Pi}]ArrayPlot[CellularAutomaton[30, {{1}, 0}, 50]]其它如 DensityPlot 和 ContourPlot,缺省使用比值 1:
DensityPlot[Sin[x] + Cos[y], {x, 0, 10}, {y, 0, 5}]ContourPlot[Sin[x] + Cos[y], {x, 0, 10}, {y, 0, 5}]可能存在的问题 (2)
在缺省情况下,ParametricPlot 可能生成一个具有极端宽高比的图形:
ParametricPlot[{u, Exp[u]}, {u, 0, 5}]利用一个显式 AspectRatio 获得合理的结果:
ParametricPlot[{u, Exp[u]}, {u, 0, 5}, AspectRatio -> 1 / GoldenRatio]利用一个显式 AspectRatio 可能使形状畸变:
ParametricPlot[{Cos[θ], Sin[θ]}, {θ, 0, 2Pi}, AspectRatio -> 1 / 2]ContourPlot[x ^ 2 + y ^ 2 == 1, {x, -1, 1}, {y, -1, 1}, AspectRatio -> 1 / 2]当形状畸变不理想时使用 Automatic:
ParametricPlot[{Cos[θ], Sin[θ]}, {θ, 0, 2Pi}, AspectRatio -> Automatic]ContourPlot[x ^ 2 + y ^ 2 == 1, {x, -1, 1}, {y, -1, 1}, AspectRatio -> Automatic]历史
1988年引入 (1.0) | 在以下年份被更新:2007 (6.0)
文本
Wolfram Research (1988),AspectRatio,Wolfram 语言函数,https://reference.wolfram.com/language/ref/AspectRatio.html (更新于 2007 年).
CMS
Wolfram 语言. 1988. "AspectRatio." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2007. https://reference.wolfram.com/language/ref/AspectRatio.html.
APA
Wolfram 语言. (1988). AspectRatio. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/AspectRatio.html 年
BibTeX
@misc{reference.wolfram_2026_aspectratio, author="Wolfram Research", title="{AspectRatio}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/AspectRatio.html}", note=[Accessed: 16-August-2026]}
BibLaTeX
@online{reference.wolfram_2026_aspectratio, organization={Wolfram Research}, title={AspectRatio}, year={2007}, url={https://reference.wolfram.com/language/ref/AspectRatio.html}, note=[Accessed: 16-August-2026]}