問題
出版用にこの図を作成したかった

解決
垂直方向のシェーディング/塗りつぶしおよび切り捨てられた法線曲線を作成するために、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
)
);
); 関数の最初の 2 つの引数は、描画される分布の「原点」または位置 (つまり、分布の中心底の (x,y) 位置) を指定します。2 番目の 2 つのオプション引数は、分布のサイズのスケーリングです。デフォルトのサイズは標準の正規分布に基づいており、スケーリングは 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 倍に拡大されます。
議論
全体的なグラフィックの一部を作成する完全なスクリプトを次に示します。このスクリプトからの出力を画像ファイルとして保存し、パワーポイントにインポートして注釈を追加し、投稿の上部に表示されているグラフィックにたどり着きました
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)};結果の出力:

関連項目
今日、自分のフィギュアを作るために引っ張り出したときにとても便利だったので、それ自体をもう一度共有したいと思いました.