0

I am writing a program for event driven simulation of elastic collision of spherical balls(in 2D). As a output of the program I am collecting the collision points into a log file(say, data.temp) and plotting them using gnuplot.

I am following the instructions discussed here in this link. My output log file looks like this.

DATA.TEMP(All points are not shown)

20.000000 0.000000 
3.535534 0.000000 
3.535534 0.000000 
45.000000 33.508349 


-20.000000 -2.500000 
-3.535534 -2.500000 
-3.535534 -2.500000 
-47.500000 -38.028654 
-47.500000 -38.028654 

The command used for gnuplot

char* commandForGnuplot[] = {"set title \"Path Plot\"","plot 'data.temp' with linespoints"};

I am able to get a plot like this enter image description here

I want the paths for different balls to be colored differently. The color should be an input from the user. How can I do this?

Community
  • 1
  • 1
bytestorm
  • 1,411
  • 3
  • 20
  • 36

1 Answers1

0

Check out gnuplot's docs: http://gnuplot.sourceforge.net/docs_4.2/node62.html

There are some examples in there for defining plot styles. You will have to do some changes in your gnuplot command string -you will probably have to define a style and change your plot command into something like this (just stick your own color in there):

set style line 1 lt rgb "#FF00FF" lw 3 pt 6
plot 'data.temp' with linespoints ls 1
dragosht
  • 3,237
  • 2
  • 23
  • 32