问题
我想为出版物创建此图

解决方案
为了创建垂直方向的阴影/填充和截断法线曲线,我使用了 Polygon() 图形函数。挑战在于能够轻松且重复地创建在图形上适当缩放和定位的多边形。我是用这个函数做的
func_VNormalShape = Function( // create a polygon that looks like a vertically oriented normal distribution
{_xloc, _yloc, _xscale = 1, _yscale = 1},
{_VNormShapeX, _VNormShapeY},
// create a vector of y values to use for plotting the shape
_VNormShapeY = ((_yloc - 3 * _yscale) :: (_yloc + 3 * _yscale) :: (_yscale / 10))`;
// create the filled polygon boundary points
_VNormShapeX = V Concat(
J( 61, 1, _xloc ),
_xloc + Sqrt( 2 * Pi() ) * _yscale * _xscale * Normal Density(
Sort Descending( _VNormShapeY ),
_yloc,
_yscale
)
);
_VNormShapeY = V Concat(
_VNormShapeY,
Sort Descending( _VNormShapeY )
);
// substitute into the Polygon(function) the two vectors with the boundary point X and Y values
// and evaluate the function
Eval(
Substitute(
Expr(
Polygon( Expr( shape_x ), Expr( shape_y ) )
),
Expr( shape_x ), _VNormShapeX,
Expr( shape_y ), _VNormShapeY
)
);
); 函数的前两个参数指定要绘制的分布的“原点”或位置(即分布中心底的 (x,y) 位置)。第二个两个可选参数是分布大小的缩放比例。默认大小基于标准正态分布,缩放比例相对于 x 方向和 y 方向。
该函数的结果是一个计算表达式,图形脚本用于将分布绘制为多边形。
例子:
func_VNormalShape(1,3) 为以 x=1、y=3 为中心的垂直方向标准正态分布创建多边形语句。
func_VNormalShape(2,4, 0.5, 1.5) 创建以 x=2, y=5 为中心的分布,但水平宽度按比例缩小 0.5,垂直宽度按比例放大 1.5。
讨论
这是创建整体图形的一部分的完整脚本。我将这个脚本的输出保存为一个图像文件,然后导入到 powerpoint 中添加一些注释,得到了帖子顶部显示的图形
names default to here(1);
func_VNormalShape = Function( // create a polygon that looks like a vertically oriented normal distribution
{_xloc, _yloc, _xscale = 1, _yscale = 1},
{_VNormShapeX, _VNormShapeY},
// create a vector of y values to use for plotting the shape
_VNormShapeY = ((_yloc - 3 * _yscale) :: (_yloc + 3 * _yscale) :: (_yscale / 10))`;
// create the filled polygon boundary points
_VNormShapeX = V Concat(
J( 61, 1, _xloc ),
_xloc + Sqrt( 2 * Pi() ) * _yscale * _xscale * Normal Density(
Sort Descending( _VNormShapeY ),
_yloc,
_yscale
)
);
_VNormShapeY = V Concat(
_VNormShapeY,
Sort Descending( _VNormShapeY )
);
// substitute into the Polygon(function) the two vectors with the boundary point X and Y values
// and evaluate the function
Eval(
Substitute(
Expr(
Polygon( Expr( shape_x ), Expr( shape_y ) )
),
Expr( shape_x ), _VNormShapeX,
Expr( shape_y ), _VNormShapeY
)
);
);
_nw=new window("Figure",
_ob=Outline Box("Figure",
_gb=Graph Box(
suppressaxes,
x scale(0,5),
y scale(-1,11),
Xname(""),
Yname(""),
fill color("gray");
func_VNormalShape(1, 8, .75, .75);
line({1,8}, {1.75, 8});
func_VNormalShape(2, 6, .75, .75);
line({2,6}, {2.75, 6});
func_VNormalShape(3, 4, .75, .75);
line({3,4}, {3.75, 4});
func_VNormalShape(4, 2, .75, .75);
line({4,2}, {4.75, 2});
linestyle(1);
Pen Size(2);
line({0.5, 5}, {4.5, 5});
)
)
);
_gb[FrameBox(1)]<<{top(0), bottom(0), left(0), right(0)};结果输出:

也可以看看
想单独分享一遍,今天拔出来做图的时候真的很方便。