Gnuplot - plotting position(xyz) vs time data inside a specified space (eg a box) with a pause

假如想象 提交于 2020-01-01 17:29:01

问题


Can the following be done in gnuplot? If yes, how?

I have data for time vs position(x,y,z) in a table with t,x,y,z as headers.

I would like to know if I can somehow plot the same time vs position of the particle inside a predefined space with a pause after each time step; so that i can see the evolution of the particles position with time. I would also like to know if I can draw a continuous line from the previous position to the current position so that I can actually see the track of its past.

Example data:

Lets say the predefined space is a box of 10x10x10 and my particle has the following positions over 3 seconds.

t x y z

0 1 2 3 

1 2 3 4

2 3 4 5

3 4 5 6

How do i see the tracking of the particle! my idea is that if i can pause the plot of every time step by a little bit, it will look like an animation which i can just capture using a screen capture software...

UNLESS, this data can be animated using gnuplot too

Is there any other software which does this more efficiently and/or elegantly if gnuplot is not the right tool!?

Any help would be appreciated!

Thanks.


回答1:


Create file main.gp and run gnuplot main.gp or load "main.gp" in gnuplot shell. Output is in point.gif. Documentation
http://www.gnuplot.info/documentation.html
Also you can type help in gnuplot shell.

main.gp

set term gif animate delay 30 size 400, 400
set output "point.gif"
do for [n=1:4] {
    splot [0:7][0:7][0:7] "data" u 2:3:4 every :::::n w lp t sprintf("n=%i", n)
}

data

t x y z

0 1 2 3

1 2 3 4

2 3 4 5

3 4 5 6

EDIT: I switched to iterations as @mgilson suggested.




回答2:


i figured it out..the code at every should be ::::n instead of the 5 colons. NOW, if i wanted to have 2 seperate files to be read and colored differently what would i do? i have this and it colors the 2 plots with red.. what if i wanted red and blue.? do for [n=1:46] { splot [0:0.002][0:0.0025][0:0.001] "data3.txt" u 2:3:4 every ::::n w lp t sprintf("n=%i", n) splot [0:0.002][0:0.0025][0:0.001] "data4.txt" u 2:3:4 every ::::n w lt 1 lw 1 pt 1 ps 1 lc rgb "blue" sprintf("n=%i", n) } ### second splot throws an error.. and if same code is used for both splots-wont wrk



来源:https://stackoverflow.com/questions/11638636/gnuplot-plotting-positionxyz-vs-time-data-inside-a-specified-space-eg-a-box

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!