How to| 图形相互对齐
Wolfram 语言图形语言有许多控件用于图形的准备和排列. 当准备图形用于演示或出版时,图形的对齐是非常重要的.
这是将 FinancialData 作为时间的函数绘制的两个图表:
p1 = DateListPlot[FinancialData["IBM", "Jan. 1, 2000"], PlotLabel -> "IBM"];
p2 = DateListPlot[FinancialData["NVDA", "Jan. 1, 2000"], PlotLabel -> "NVIDIA"];GraphicsGrid[{{p1}, {p2}}](Wolfram 系统自动使绘图区尽可能大,并只给轴标签提供必要的空间. 通常这是理想的,但这种情况例外.)
解决方法是利用 ImagePadding 选项为图形手动设置填充:
padding = {{30, 30}, {30, 30}};
p1 = DateListPlot[FinancialData["IBM", "Jan. 1, 2000"], PlotLabel -> "IBM", ImagePadding -> padding];
p2 = DateListPlot[FinancialData["NVDA", "Jan. 1, 2000"], PlotLabel -> "NVIDIA", ImagePadding -> padding];GraphicsGrid[{{p1}, {p2}}]您也可以使用 ImagePadding 使图形水平对齐.