Timestamp frequency histogram

Dear GMT Comunity,

Given a series of hour:minute timestamps like


I would like to plot a frequency histogram as below (color, spacing, horizontal lines, etc. don’t matter)

I already managed to write binned data to sdtout (after having prepended each data line with a “T”)
gmt pshistogram <timestamp.log> -T1 -fT -Io

But now I struggle turning this into a chart. E.g.
gmt <timestamp.log> -Jx1t/y1t -T1 -fT -Gblack
returns a blank sheet only.

How do I use -J option properly?
Do I miss anything important?
Can I / how use my raw data directly (“14:34”) instead of prepending “T” (“T14:34”).



Do you already know the y-value associated to 14:34(…) ? If that’s the case, psxy or plot using -Sb option might be more suited …

Or do you actually want to compute the frequency ?

No I don’t know y values in advance. They are determined by counting the number of occurences of each value per bin.
When I pipe the stdout of pshistogram to psxy I still get a clean sheet. I’m afraid, psxy requires the same -J or -T or -R options which I don’t understand how to use in the first place.

In gmt 5 (which I assume you’re using) -R defines the limits of your domain :

Corresponds to a “map” with x =[0:100] and y =[-1:1].

-J corresponds to the “map projection”, in your case the plot is in cartesian coordinates:

-Jx or -JX

The -T option is to be used to specify the bin width

In the case you’re using gmt 6, -R and -J are dealt implicitly in begin command … and the module for histograms is just histogram without “ps”.

Thanks again! I’m using gmt 6.0.0.

Eventually, I got my desired output.

It was a combination of things that I did wrong.
When I added -B options for axes labels, I got my first non-blank sheet which was very helpful to identify my mistakes:
There was a syntax error in my -J option (no “y” behind the separating slash).
After I fixed that, I got more output to play with and started to understand the effects of my changes.

Here’s what I came up with eventually:
gmt pshistogram <timestamp.log>-JX25T/10 -TT00:00:00/T23:59:59/1440+n -fT -Bx2H+l"Time" -By+l"Frequency" -BWS -Gblack

My options explained as I understood them (for anybody interested):
-JX25T/10 chart dimensions in absolute values, 25cm wide and time based, 10cm high
-TT00:00:00/T23:59:59/1440+n histogram bins from min value 00:00 to max value 23:59:59 with 1440 bins (= minutes per day)
-fT use abolute time based
-Bx2H+l"Time" x-axis labeled “Time” with 2 hour ticks
-By+l"Frequency" y-axis labeld “Frequency” with auto-/default-ticks
-BWS show only left (west) and bottom (south) axes, hide top and right
-Gblack fill bars black

1 Like