neustre nitch
neustre nitch

Reputation: 103

make a condition in gnuplot when the valeur of column is a string

I have this file data.dat in gnuplot and i want to plot a graph that shows me the percentage of failures in the system according to 'hardware' and 'software' per year. here is te data (minimal):

 ticket_id  time_down   time_up minutes_down    category    type    description    
        23350   01/15/06 07:24 PM   01/16/06 02:19 PM   1135    "HARDWARE"  "UNSCHEDULED"   " NGF - HARDWARE - UNSCHEDULED - TLFSSV05 DOWN"
        23351   01/16/06 01:21 AM   01/16/06 01:34 AM   13.3    "HARDWARE"  "UNSCHEDULED"   " NGF - HARDWARE - UNSCHEDULED - TLFSSV06 DOWN"
        23353   01/16/06 04:18 AM   01/16/06 04:49 AM   31  "HARDWARE"  "UNSCHEDULED"   " NGF - HARDWARE - UNSCHEDULED - TLFSSV01 DOWN"
        23355   01/16/06 04:20 AM   01/16/06 05:54 AM   94  "SOFTWARE"  "UNSCHEDULED"   " NGF - SOFTWARE - UNSCHEDULED - TLFSSV09 - HOST DOWN"
        23356   01/16/06 04:21 AM   01/16/06 04:59 AM   38  "SOFTWARE"  "UNSCHEDULED"   " NGF - SOFTWARE - UNSCHEDULED - TLFSSV13 - HOST DOWN"
        23357   01/16/06 04:23 AM   01/16/06 04:59 AM   36  "SOFTWARE"  "UNSCHEDULED"   " NGF - SOFTWARE - UNSCHEDULED - TLFSSV02 - HOST DOWN"

i tried this to first sort falures by "hardware" :

plot 'hope.dat' u  ($3-$2):4:($5=='"HARDWARE"') w histogram

but i get this error :Non-numeric string found where a numeric expression was expected

Upvotes: 0

Views: 2996

Answers (1)

Christoph
Christoph

Reputation: 48420

  • In order to check for a string you must use stringcolumn(5) instead of $5 (a shortcut for column(5), which gives the numerical value of the column).

  • string comparison is done with eq.

  • When plotting with histogram, gnuplot itself uses integer x-positions. Probably you want to use with boxes.

  • You cannot just use normal subtraction for two different time data.

  • Since you have white spaces inside the time values, your column counting is wrong.

  • Gnuplot cannot handle am and pm in the input.

Upvotes: 2

Related Questions