Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Histogram with x axis date error

491 views
Skip to first unread message

dmulter

unread,
Sep 17, 2009, 7:04:15 PM9/17/09
to
Maybe I'm missing something easy, but I don't think so. I've been
using gnuplot for many graphs, and have run into a problem I can't
solve for one case. The following data and plot commands graphs
correctly:

Bugzilla_ArrivalsSev.dat:
Date blocker critical major normal total
2008-12-08 1 0 1 0 2
2009-02-13 1 0 0 0 1
2009-02-16 3 1 1 1 6
2009-02-17 1 1 1 1 4
2009-02-18 1 1 1 0 3
2009-02-19 0 0 0 3 3
2009-02-20 1 0 0 1 2
2009-03-03 1 0 1 0 2
2009-06-25 4 3 3 1 11

$ gnuplot
set terminal png nocrop enhanced font Verdana 8 size 400,300
set title "Arrivals By Severity" font "Verdana-Bold,10"
set key outside
set xlabel "Time"
set ylabel "Bug Count"
set xdata time
set timefmt "%Y-%m-%d"
set format x "%m-%d-%y"
set xtic rotate by -75
set style data linespoints
set style fill solid 1.0 border -1
set output "Bugzilla_ArrivalsBySeverity.png"
plot 'Bugzilla_ArrivalsSev.dat' using 1:6 title columnhead

Again, the data file plus the commands above generate a good line
graph with no error. I change the plot commands to a histogram by
modifying 2 lines (set style data histogram, and plot...), I get a
"Need full using spec for x time data" error from gnuplot.

$ gnuplot
set terminal png nocrop enhanced font Verdana 8 size 400,300
set title "Arrivals By Severity" font "Verdana-Bold,10"
set key outside
set xlabel "Time"
set ylabel "Bug Count"
set xdata time
set timefmt "%Y-%m-%d"
set format x "%m-%d-%y"
set xtic rotate by -75
set style data histogram
set style fill solid 1.0 border -1
set output "Bugzilla_ArrivalsBySeverity.png"
plot 'Bugzilla_ArrivalsSev.dat' using 6 title columnhead

I understand the parsing challenge for gnuplot when processing time
data, but I do have the "set timefmt" commands specified, and they
work when doing a line plot as I said before. I have no idea why it
would fail when I use a histogram. Any ideas? Is this a bug?

I'm running 4.2.6 on Mac OS X 10.5.8.

Thanks,
David

sfeam

unread,
Sep 17, 2009, 11:10:41 PM9/17/09
to
dmulter wrote:

I suspect that the histogram data style doesn't do what you think.
It is intended for comparing parallel columns of data, not for
plotting a single column.

Try instead
set style data boxes
set boxwidth abs <some number>
or
set style data impulses


> I understand the parsing challenge for gnuplot when processing time
> data, but I do have the "set timefmt" commands specified

But histogram plots do not use or want an x-axis coordinate at all.
[There can be exceptions, but your commands don't look like they
are aiming in that direction]

I think you are confusing the program by telling it that the x axis
wants time coordinates, when it is expecting to use the x axis only
to separate 'category 1' from 'category 2', etc. using integers.


dmulter

unread,
Sep 18, 2009, 12:01:43 AM9/18/09
to

The plot I want to generate is across columns, not in a single column.
What I'm looking for is:

bcmnt bcmnt bcmnt ...
12/8 2/13 2/16 ...

Where "bcmnt" are 5 vertical bars representing the row numeric values
for each row date. So the date runs along the x-axis, and the bars run
represent clustered values for each severity category in the row. Hope
this makes sense.

dmulter

unread,
Sep 18, 2009, 12:07:17 AM9/18/09
to

My graph output should look like the #2 example from
http://gnuplot.sourceforge.net/demo/histograms.html, but I'm using
real dates instead of just strings on the x-axis.

dmulter

unread,
Sep 18, 2009, 12:20:32 AM9/18/09
to
> My graph output should look like the #2 example fromhttp://gnuplot.sourceforge.net/demo/histograms.html, but I'm using

> real dates instead of just strings on the x-axis.

One last thing, I simplified the plot command to only use one column
to illustrate the issue. The full command fails with the error on
processing of the first <using> section, but the full version to
generate the plot I want is:

plot 'Bugzilla_ArrivalsSev.dat' u 2:xtic(1) ti col, '' u 3 ti col, ''
u 4 ti col, '' u 5 ti col

sfeam

unread,
Sep 18, 2009, 2:31:20 AM9/18/09
to
dmulter wrote:

> On Sep 17, 9:07 pm, dmulter <dmul...@gmail.com> wrote:
>> On Sep 17, 9:01 pm, dmulter <dmul...@gmail.com> wrote:

>> > > > $ gnuplot
>> > > > set terminal png nocrop enhanced font Verdana 8 size 400,300
>> > > > set title "Arrivals By Severity" font "Verdana-Bold,10"
>> > > > set key outside
>> > > > set xlabel "Time"
>> > > > set ylabel "Bug Count"
>> > > > set xdata time
>> > > > set timefmt "%Y-%m-%d"
>> > > > set format x "%m-%d-%y"
>> > > > set xtic rotate by -75
>> > > > set style data linespoints
>> > > > set style fill solid 1.0 border -1
>> > > > set output "Bugzilla_ArrivalsBySeverity.png"
>> > > > plot 'Bugzilla_ArrivalsSev.dat' using 1:6 title columnhead

^^^^^^^^^^


>> > > > Again, the data file plus the commands above generate a good
>> > > > line graph with no error. I change the plot commands to a
>> > > > histogram by modifying 2 lines (set style data histogram, and
>> > > > plot...),

>> > > I think you are confusing the program by telling it that the x


>> > > axis wants time coordinates, when it is expecting to use the x
>> > > axis only to separate 'category 1' from 'category 2', etc. using
>> > > integers.
>>
>> > The plot I want to generate is across columns, not in a single
>> > column. What I'm looking for is:
>>
>> > bcmnt bcmnt bcmnt ...
>> > 12/8 2/13 2/16 ...
>>
>> > Where "bcmnt" are 5 vertical bars representing the row numeric
>> > values for each row date. So the date runs along the x-axis, and
>> > the bars run represent clustered values for each severity category
>> > in the row. Hope this makes sense.

Yes, but the point is that the histogram plot style doesn't use
x-coordinates. You can't say: 'plot ... using 1:6 with histograms'
because it only wants a y-coord: 'plot ... using 6 with histograms'.

The program generates sequential integers as the x coordinate internally
so that you get evenly-spaced clusters of histogram bars.
And because it is only generating integral x=0,1,2,3,... it complains
when you tell it that the x-axis is in time units.

>> My graph output should look like the #2 example
>> fromhttp://gnuplot.sourceforge.net/demo/histograms.html, but I'm
>> using real dates instead of just strings on the x-axis.
>
> One last thing, I simplified the plot command to only use one column
> to illustrate the issue. The full command fails with the error on
> processing of the first <using> section, but the full version to
> generate the plot I want is:
>
> plot 'Bugzilla_ArrivalsSev.dat' u 2:xtic(1) ti col, '' u 3 ti col, ''
> u 4 ti col, '' u 5 ti col

That should work to generate evenly spaced clustered labeled with the date,
but you can't use that form of command to change the spacing along x.

The closest I can think of is to use stacked histograms rather than
clustered histograms. Then you can place each stack wherever you
want along the x axis.:

set style data histogram
set style histogram columns

plot newhistogram at <date>, 'day1' using 1, \
newhistogram at <date>, 'day2' using 2, \
...

But it will be hard to pull the x-coordinate date out of the data file,
and I think that to make this work you need to flip your data file
format so that the columns are dates and the rows are the categories.

dmulter

unread,
Sep 18, 2009, 1:37:07 PM9/18/09
to

Thanks for the explanation, it helps. My real goal was not to change
the spacing along the x-axis, but merely to have gnuplot parse the
date/time data from my data file, and then allow me to reformat for
display in a different format as labels along the x-axis. I didn't
want it to alter the spacing in any way. I can see how the x-axis
commands would be confusing to gnuplot in this case.

Since I can do histograms with x-axis labels, I think there should be
some way to have it parse date/time labels and let me reformat as
needed. It could easily prevent me from using such commands to alter
how it renders the x-axis portion of the graph. FYI, I've just
resorted to formatting the date the way I want in the data file, and
then have it just use it as a label without any x-axis time/date
commands. I do think this is a bug anyway.

sfeam

unread,
Sep 18, 2009, 4:54:04 PM9/18/09
to
dmulter wrote:
>Bugzilla_ArrivalsSev.dat:
Date blocker critical major normal total
2008-12-08 1 0 1 0 2
2009-02-13 1 0 0 0 1

> Thanks for the explanation, it helps. My real goal was not to change


> the spacing along the x-axis, but merely to have gnuplot parse the
> date/time data from my data file, and then allow me to reformat for
> display in a different format as labels along the x-axis. I didn't
> want it to alter the spacing in any way. I can see how the x-axis
> commands would be confusing to gnuplot in this case.

Now if you had just explained that in the first place,....

# Simple example using pure string processing
# You can define far more complex reformatting commands if you like
# Change date of the form 2008-12-08 to 08-12-2008
reformat(date) = date[9:10].date[5:8].date[1:4]

# Now plot it, generating tick labels by reformatting contents of column 1
plot 'foo' using 2:xtic( reformat(stringcolumn(1) )

> Since I can do histograms with x-axis labels, I think there should be
> some way to have it parse date/time labels and let me reformat as
> needed.

See also the available functions strftime() and strptime()

> It could easily prevent me from using such commands to alter
> how it renders the x-axis portion of the graph. FYI, I've just
> resorted to formatting the date the way I want in the data file, and
> then have it just use it as a label without any x-axis time/date
> commands. I do think this is a bug anyway.

At this point I've lost track of what "this" is, that you think is a bug.


0 new messages