如何绘制具有3个或更多列的离散数据集?我们的情况如下:
/* Required essentially to create the data set */
eqn1: 4 - x^2 - 4*y^2$
eqn2: y^2 - x^2 + 1$
sol: rk([eqn1,eqn2],[x,y],[-1.25, 0.75],[t,0,4,0.2])$
/* My current workaround to plot (x vs t) and (y vs t) */
n : length(sol)$
/* Select the ith column and create separate lists */
tseries : makelist(sol[i][1], i, 1, n)$
xseries: makelist(sol[i][2], i, 1, n)$
yseries: makelist(sol[i][3], i, 1, n)$
plot2d([
[discrete, tseries, xseries],
[discrete, tseries, yseries]
], [legend,"x","y"] ,[xlabel,"t"], [ylabel,"x, y"],[style,
[linespoints,2,2]],
[gnuplot_preamble,"set key box width 2 spacing 1.3 top left"])$是否有更好的解决方案来绘制,而不需要创建tseries、xseries和yseries列表?
发布于 2018-12-12 17:52:08
好的,基于你的评论,我明白了目标是什么。您的解决方案可以稍微简短一点,虽然不是很多。无论如何,map(lambda([txy], [txy[1], txy[2]]), sol)生成t,x点的列表,map(lambda([txy], [txy[1], txy[3]]), sol)生成t,y点的列表。因此,对于上面给出的sol,我发现
plot2d ([[discrete, map(lambda([txy], [txy[1], txy[2]]), sol)],
[discrete, map(lambda([txy], [txy[1], txy[3]]), sol)]]);具有所需的输出(为了清晰起见,省略绘图选项)。
https://stackoverflow.com/questions/53726184
复制相似问题