1

Hi I want to plot multiple (x,y) coordinates in a single graph. Say I have a data file which has the contents like the following:

 x      y
0.0    0.5
0.12   0.1
0.16   0.4
0.2    0.35
0.31   0.8
0.34   0.6
0.38   1.0
0.46   0.2
0.51   0.7
0.7    0.9

could I have a some more data in this file like,

 x     y       x1     y1
0.0    0.5    0.04    0.7   
0.12   0.1    0.08    0.74 
0.16   0.4    0.12    0.85
0.2    0.35   0.16    0.9
0.31   0.8    0.2     0.53
0.34   0.6    0.24    0.31
0.38   1.0    0.28    0.87
0.46   0.2    0.32    0.20
0.51   0.7    0.36    0.45
0.7    0.9    0.4     0.64

and plot the graph on gnuplot where (x,y) and (x1,y1) would all be in a single curve? Thank you.

6
  • When you say single curve do you mean that you would first plot all the (x,y) values then plot the (x1,y1) values? In other words (x1,y1) is basically more (x,y) values? Commented Aug 18, 2011 at 14:47
  • Yes. This should generate bezier curves end to end starting from 1st (x,y) to second to third and so on. The (x1,y1) are actually the points lying in each curve. Here, the y and y1 values are random but x and x1 values are correct. I am still working on getting the correct y and y1 values. And by the time I also have to make sure that the curves are generating though it would be weird right now. Thanks Commented Aug 18, 2011 at 15:19
  • Ah okay, well if you're working with bezier curves can you use the matplotlib? In which case I think this will help you matplotlib.sourceforge.net/users/… Commented Aug 18, 2011 at 15:25
  • I am sorry but I actually have to do them in gnuplot as I am doing a research and thats what is expected. Thanks. Commented Aug 18, 2011 at 15:32
  • Ah okay, potentially this may help you then t16web.lanl.gov/Kawano/gnuplot/plot2-e.html - unfortunately I haven't learned enough math in regards to bezier curves so that's probably the best I'll be able to send to you. Commented Aug 18, 2011 at 15:39

1 Answer 1

2

gnuplot can only plot column format data as far as I know. That said, you will have to plot it in after transpose your data as follows:

x  0.000000 y  0.500000 x  0.120000 y  0.100000  ...
x1 0.040000 y1 0.700000 x1 0.080000 y1 0.740000  ...

and plot data us 1:2, data us 3:4, data us 5:6.

To transpose the data, you can either change your program to write it in this way, or use following awk script:

awk '{for (i=1;i<=NF;i++) arr[NR,i]=$i;} END{for (i=1;i<=NF;i=i+2) {for (j=1;j<=NR;j++) {printf "%f %f ",arr[j,i],arr[j,i+1]} print ""}}' datafile
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.