4

I have data something like this:

# c1 c2 c3
23 b 323
23 g 54
23 a 11
23 c 1
23 d 0
23 e 397
23 f 40
24 b 23
24 g 24
24 a 113
24 c 12
24 d 10
24 e 7
24 f 50

I need to plot with c1 on x-axis (23,24), c3 on y-axis for different values of c2 i.e, multiple graphs with different colors for each value of c2.

enter image description here

GP92
  • 433
  • 1
  • 12
  • 30

1 Answers1

2

In general, you must do the filtering outside of gnuplot, in order to have lines connecting the filtered points.

If you know all values which can appear in the second column, you can use the solution given in Plotting multiple graphs depending on column value with gnuplot.

If you don't know the possible values, you can extract them with

c2s = system("awk '!/^#/ { print $2 }' test.dat | sort | uniq")

and then plot them with

plot for [c2 in c2s] sprintf('< grep ''\b%s\b'' test.dat', c2) using 1:3 with lines title c2

enter image description here

Community
  • 1
  • 1
Christoph
  • 47,569
  • 8
  • 87
  • 187
  • @Chirstoph Hi How can we genrate historgram from similar data?? – GP92 May 02 '15 at 12:36
  • It depends on how your histogram actually should look like (stacked, clustered etc) Would be best to ask a new question and describe what you exactly want to achieve, and were you got stucked. – Christoph May 02 '15 at 13:22