作为参考,以下是使用以下方法在两个单独的图中绘制两个数据集的方法plothraw
:
\\ As two separate plots using plothraw
plothraw([0..200], apply(i->sin(i*3*Pi/200), [0..200]), 0);
plothraw([0..200], apply(i->cos(i*3*Pi/200), [0..200]), 0);
第一个解决方案使用ploth
:
{ploth(i=0, 200, [i, sin(i*3*Pi/200), i, cos(i*3*Pi/200)], "Parametric|no_Lines", 200);}
第二个解决方案使用低级函数,但我无法让颜色工作(显然在 X-windows 上支持,但在 Windows 上不支持):
{my(s=plothsizes());plotinit(0,s[1]-1,s[2]-1);}
plotscale(0, 0, 200, -1, 1);
plotcolor(0, 2); \\ blue
plotrecthraw(0, [ [0..200], apply(i->sin(i*3*Pi/200), [0..200]) ], 0);
plotcolor(0, 4); \\ red
plotpoints(0, [0..200], apply(i->cos(i*3*Pi/200), [0..200]));
plotdraw([0,0,0]); \\ draws window 0 at (0,0)
plotkill(0); \\ frees memory of window 0
第一个解决方案可能是最容易使用的(特别是如果您不希望所有内容都具有相同的颜色)。如果你有 4 个向量的数据,比如说vx
, vy
, ux
, uy
所有的长度都相同#vx == #vy == #ux == #uy
那么正确的形式是:
\\ first 2 lines just create test vectors
vx=[0..200]; vy=apply(i->sin(i*3*Pi/200), [0..200]);
ux=[0..200]; uy=apply(i->cos(i*3*Pi/200), [0..200]);
\\ the actual plot - the \1's just round to integer index
{ploth(i=1, #vx, [vx[i\1], vy[i\1], ux[i\1], uy[i\1]], "Parametric|no_Lines", #vx);}