4

I'd like to draw an impulse graph from a text file that looks like this:

II 5 0 0 288.40 1.3033e+14 
II 6 0 0 289.60 1.5621e+14 
II 1 4 0 302.70 3.0084e+13 
II 2 4 0 303.40 4.0230e+13 
II 1 5 1 304.40 3.4089e+13

The plot conceptually should be plot "datafile.dat" using 5:6 w impulses ls $2.

Basically, given a previously defined set of line styles, I'd like to input the line style number from column 2 for every couple of plotted points from column 5 and 6.
Also I'd like to create a text box, for every plotted point, taking strings from the first four columns.

Does somebody know if that's possible?

3 Answers 3

5

To use the data from column two as line style use set style increment user and linecolor variable:

set style increment user
plot "datafile.dat" using 5:6:2 with impulses lc var

In order to place a label, use the labels plotting style:

plot "datafile.dat" using 5:6:1 with labels offset 0,1

Putting everything together, you have:

set style increment user
set for [i=1:6] style line i lt i
set yrange [0:*]
set offsets 0,0,graph 0.1,0
plot "datafile.dat" using 5:6:2 with impulses lc var, "" using 5:6:1 with labels offset 0,1

The result with 4.6.3 is:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

1

Thanks for the helpful answer above. It almost solved my problem

I'm actually trying to use a column from my data file to specify a linestyle (dot, squares,triangles, whatever as long as it's user-defined), and not a linecolor. Is there any way to do that?

This line works : I get points with different colors (specified in column 4), but the point style is the same.

plot "$file" u 1:2:4 w p notitle lc var, "" using 1:2:3 with labels offset 0,1 notitle

Replacing lc with ls after defining my own styles doesn't work (ls can't have variable as an option) I can live without different linestyles, but it would be much prettier.

Comments

1

You only have to replace the lineset for [i=1:6] style line i lt i for set for [i=1:6] style line i lt i pt %, Where % can be any type of point you want

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.