# Real time updation in gnuplot

Last summer, two of my friends and I did a project under Programming Club, IITK. The topic of the project was N-Body Simulation, and we had to write parallelised code to simulate the motion of a specified number of bodies (~30) with specified ‘masses’ under a ‘gravitational force’ acting between each of them. For this purpose we had to have something that could plot the data obtained in real time. We gave a lot of importance to this real time updation because otherwise we were generating text files in the gigabyte range which then took ages to plot. We tried various options, including Matlab, the matplotlib and scipy libraries in Python, but didn’t get the speed required for our work in any of them. Finally we stumbled upon a solution to this problem, in which we used gnuplot with a pause/reread instruction, and that solved our problem perfectly.The required commands in gnuplot are

pause


The specific code is shown below

set term x11 size 1500, 1200
set xrange [-500:500]
set yrange [-500:500]
set zrange [-5:5]
splot "List.txt" with points ps 1 pt 7 title "N-Body Simulation"
pause 1