0

I have a file that I need to plot in a graph that looks similar to this: gnuplot sample graph

Here is my file that I am trying to plot:

441.81   823.36   192765   3044.68   4242.61
X        2609.3   4901.96  8306.6    12058.18
1632.27  4098.15  9299.14  16295.19  24665.59

I can do a simple plot, but changing the line types and using a file is what I am having trouble with. I'm not sure how to get the data from the file into the plot and make it formatted like the sample image.

1
  • what do you want to plot, specifically? It seems that you want to plot each row and not the columns, doesn't it? Commented Dec 2, 2015 at 0:44

1 Answer 1

1

You probably should dig a little deeper into gnuplot. A good start is this article on plotting data.

Anyway, let's define three distinct line styles:

set style line 1 lc 'blue' lt 1 lw 2 pt 6 ps 1.5  
set style line 2 lc 'red' lt 1 lw 2 pt 6 ps 1.5  
set style line 3 lc 'green' lt 1 lw 2 pt 6 ps 1.5  

Then, we can call the plot function on our inputFile:

plot 'inptFile' u 1:2 w lp ls 1, '' u 1:3 w lp ls 2, '' u 1:4 w lp ls 3

(u 1:2 stands for using 1:2 and means that we use the value in the first column as x-coordinate and the value in the second column as the y-coordinate. )

Note that our inputFile looks like this (i.e., each line contains a point's x and y-coordinate):

-1 2 3 4
0 1 2 4
1 2 4 16
2 3 16 8

Output: enter image description here

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.