Rohith Suresh
Rohith Suresh

Reputation: 11

gnuplot throws error: Too many columns in using specification

I wish to plot

Date,usrCPU,sysCPU
2014/11/12-00:01:08,14,4
2014/11/12-01:05:18,19,5
2014/11/12-02:06:28,22,4
2014/11/12-03:20:38,21,4
2014/11/12-04:30:48,21,4
2014/11/12-05:40:58,23,5
2014/11/12-06:51:08,22,4
2014/11/12-07:52:18,23,4
2014/11/12-08:55:28,24,6

I am using the following gnuplot

set title "Pset plot
set datafile separator ","
set terminal jpeg giant font "Helvetica" 16
set style data histograms
set style histogram rowstacked
set xdata time
set timefmt "%Y/%m/%d-%H-%M-%S"
set xlabel "Time"
set ylabel "percentage"
set xrange["2014/11/12-00:00:00":"2014/11/12-20:00:00"]
set ytics 10
set autoscale
set output 'pset.png'
plot 'pset1_betsy.csv' using 1:2 title "UsrCPU", '' using 1:3 title "sysCPU"

But it throws the following error

"pset.plot", line 14: Too many columns in using specification

Please help me with this error.

Upvotes: 1

Views: 1844

Answers (1)

Christoph
Christoph

Reputation: 48400

You cannot use the histogram properly together with time data or any kind of continuous data. The x-values for each box are computed internally to be at integer positions, and you can give those boxes labels (possibly also dates).

To plot boxes for continuous data and stack those values, you must either plot with boxes, or use boxxyerrorbars with a lot of fiddling:

set title "Pset plot"
set datafile separator ","
set terminal pngcairo
set xdata time
set timefmt "%Y/%m/%d-%H-%M-%S"
set xlabel "Time"
set ylabel "percentage"
set xrange["2014/11/12-00:00:00":"2014/11/12-20:00:00"]
set yrange [0:*]
set output 'pset.png'
set style fill solid
set style data boxes
set boxwidth 0.8 relative
plot 'pset1_betsy.csv' using 1:($2+$3) title "sysCPU", '' using 1:2 title "UsrCPU"

For the first plot I use the sum of second and third column to simulate stacking.

enter image description here

Upvotes: 2

Related Questions