Question

I would like to do graph from these data:

(cur | prev) 01:22, 30 March 2011? Sergio (Talk | contribs)? . . (20,789 bytes) (+4)? . . (>?VoIP)
(cur | prev) 01:23, 30 March 2011? Sergio (Talk | contribs)? . . (20,790 bytes) (+1)? . . (>?VoIP)
(cur | prev) 01:25, 30 March 2011? Sergio (Talk | contribs)? . . (20,950 bytes) (+160)? . . (>?VoIP)
(cur | prev) 10:15, 30 March 2011? Tcatm (Talk | contribs)? . . (21,028 bytes) (+78)? . . (>?Virtual goods)
(cur | prev) 12:43, 30 March 2011? Doood (Talk | contribs)? . . (21,173 bytes) (+145)? . . (>?Home)
(cur | prev) 12:43, 30 March 2011? Doood (Talk | contribs)? . . (21,162 bytes) (-11)? . . (>?Home)

I need to do graph with dates on x-axis and count of lines on y-axis Example:

x-axis = "30/3" y-axis = "6" ( six lines on 30 March )
x-axis = "31/3" y-axis = ....

How can I do this graph by code in gnuplot?

Était-ce utile?

La solution

Assuming you have the same format for all your entries, that is the month day is always the fifth column in your data file, then do the following:

set xdata time
set timefmt "%d %B %Y"
set format x "%d/%m"
plot "data" u 5:(1.0) smooth freq with lp pt 7

The first line tells gnuplot to interpret the data as time data.

The second line tells gnuplot in what format the time data needs to be read: %d is the day, %B is the month in full name (that is "March" instead of "3" or "Mar"), %Y is the year with four digits.

The third line tells gnuplot in what format to print the date on the plot, %d for day and %m for month (in digit form) separated by a /.

The fourth line plots your data file, using the 5th column in the x axis (your data is the 5th entry in your data file as you posted it) and adding 1 for each entry. The latter is achieved with the smooth freq option. Then I added some style to better visualize what is being plotted with lp pt 7, but you can freely modify that to your liking.

I modified you sample data to the following, just as an example:

(cur | prev) 01:22, 28 March 2011? Sergio (Talk | contribs)? . . (20,789 bytes) (+4)? . . (>?VoIP)
(cur | prev) 01:23, 28 March 2011? Sergio (Talk | contribs)? . . (20,790 bytes) (+1)? . . (>?VoIP)
(cur | prev) 01:25, 29 March 2011? Sergio (Talk | contribs)? . . (20,950 bytes) (+160)? . . (>?VoIP)
(cur | prev) 01:22, 29 March 2011? Sergio (Talk | contribs)? . . (20,789 bytes) (+4)? . . (>?VoIP)
(cur | prev) 01:23, 30 March 2011? Sergio (Talk | contribs)? . . (20,790 bytes) (+1)? . . (>?VoIP)
(cur | prev) 01:25, 30 March 2011? Sergio (Talk | contribs)? . . (20,950 bytes) (+160)? . . (>?VoIP)
(cur | prev) 10:15, 30 March 2011? Tcatm (Talk | contribs)? . . (21,028 bytes) (+78)? . . (>?Virtual goods)
(cur | prev) 12:43, 30 March 2011? Doood (Talk | contribs)? . . (21,173 bytes) (+145)? . . (>?Home)
(cur | prev) 12:43, 31 March 2011? Doood (Talk | contribs)? . . (21,162 bytes) (-11)? . . (>?Home)

With the code at the beginning of my answer, this data looks like this:

enter image description here

If you would prefer a histogram-like graph, have a look at this question.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top