如何绘制具有 3 列或更多列的离散数据集? MWE如下:
/* 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
列表?
最佳答案
好的,根据您的评论,我明白了目标是什么。您的解决方案可以更简短一些,尽管不是很多。无论如何,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)]]);
具有所需的输出(为了清晰起见,省略了绘图选项)。
关于plot - Maxima 用 3 列绘制离散数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53726184/