Problem
Ich wollte diese Figur für eine Publikation erstellen

Lösung
Um die vertikal ausgerichteten schattierten/gefüllten und abgeschnittenen normalen Kurven zu erstellen, habe ich die Grafikfunktion Polygon() verwendet.Die Herausforderung bestand darin, einfach und wiederholt in der Lage zu sein, dieses Polygon zu erstellen, das angemessen skaliert und auf einem Diagramm positioniert wurde.Ich habe das mit dieser Funktion gemacht
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
)
);
); die ersten beiden Argumente der Funktion spezifizieren den "Ursprung" oder Ort der zu zeichnenden Verteilung (dh die (x,y)-Position für die zentrale Basis der Verteilung).Die zweiten beiden optionalen Argumente sind die Skalierung der Größe der Verteilungen.Die Standardgröße basiert auf einer Standardnormalverteilung, und die Skalierung erfolgt relativ zur x- und y-Richtung.
Das Ergebnis der Funktion ist ein ausgewerteter Ausdruck, der von einem Grafikskript zum Zeichnen der Verteilung als Polygon verwendet wurde.
Beispiele:
func_VNormalShape(1,3) erstellt die Polygonanweisung für eine vertikal ausgerichtete Standardnormalverteilung mit dem Mittelpunkt x=1, y=3.
func_VNormalShape(2,4, 0,5, 1,5) erstellt die Verteilung zentriert bei x=2, y=5, aber die horizontale Breite wird um den Faktor 0,5 verkleinert und die vertikale Breite um den Faktor 1,5 vergrößert.
Diskussion
Hier ist das vollständige Skript, das einen Teil der Gesamtgrafik erstellt.Ich habe die Ausgabe dieses Skripts als Bilddatei gespeichert und dann in Powerpoint importiert, um einige Anmerkungen hinzuzufügen, und bin zu der Grafik gelangt, die oben im Beitrag angezeigt wird
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)};resultierende Ausgabe:

Siehe auch
Ich wollte es nochmal alleine teilen, da es heute sehr praktisch war, als ich es herausgezogen habe, um meine Figur zu machen.