|
From: Dima K. <gn...@di...> - 2021-07-26 00:36:16
|
Hi. I just tried to patch gnuplot to do something that I thought would be simple, but it actually looks like it wouldn't be. Can I get a suggestion? I'm making a simple histogram. This works as expected: set boxwidth 1 histbin(x) = floor(0.5 + x) plot '-' using (histbin($1)):(1.0) smooth freq with boxes fill solid border lt -1 1 2 4 5 e Here I get 4 bins of width 1, centered at 1, 2, 4, 5. Notably, there's a gap: there's no bin centered at 3. Internally, gnuplot omits this bin entirely, instead of producing an empty bin. This matters if you make a this plot "with linespoints" instead of "with boxes". I want a plot that includes the point (3,0), but the current code doesn't include that point. Is there an obvious way to include that? Thanks! |
|
From: Ethan A M. <me...@uw...> - 2021-07-26 05:52:15
|
Not sure I understand what kind of plot you are aiming for,
and you don't give an example of the real data format,
but how about initializing all the bins to zero?
# initialize a bunch of bins to zero
set print $BINS
do for [i=1:10] { print i, 0.0 }
unset print
# add the real data to those same bins
set table $BINS append
plot DATA using (histbin($1)):(1.0) with table
unset table
# now plot the data as before
plot $BINS using 1:2 smooth freq with boxes fill solid border lt -1
Ethan
On Sunday, 25 July 2021 17:20:13 PDT Dima Kogan wrote:
> Hi. I just tried to patch gnuplot to do something that I thought would
> be simple, but it actually looks like it wouldn't be. Can I get a
> suggestion?
>
> I'm making a simple histogram. This works as expected:
>
> set boxwidth 1
> histbin(x) = floor(0.5 + x)
> plot '-' using (histbin($1)):(1.0) smooth freq with boxes fill solid border lt -1
> 1
> 2
> 4
> 5
> e
>
> Here I get 4 bins of width 1, centered at 1, 2, 4, 5. Notably, there's a
> gap: there's no bin centered at 3. Internally, gnuplot omits this bin
> entirely, instead of producing an empty bin. This matters if you make a
> this plot "with linespoints" instead of "with boxes". I want a plot that
> includes the point (3,0), but the current code doesn't include that
> point. Is there an obvious way to include that?
>
> Thanks!
|
|
From: Dima K. <gn...@di...> - 2021-07-27 06:16:10
|
Ethan A Merritt <me...@uw...> writes:
> Not sure I understand what kind of plot you are aiming for, and you
> don't give an example of the real data format
Hi. The little example was a close approximation to what I want. If it
helps, here's what I REALLY want. I have a data file with sorted
timestamps, one per line, that record the time when something failed. I
want to make a plot of "failures per hour", as a function of time. So I
want to consolidate the data into bins, but instead of "with boxes", I'd
like to plot "with lines". Currently this doesn't work the way I want
because any hour blocks that have 0 failures in them don't get a y=0
point in the line plot.
> but how about initializing all the bins to zero?
>
> # initialize a bunch of bins to zero
> set print $BINS
> do for [i=1:10] { print i, 0.0 }
> unset print
> # add the real data to those same bins
> set table $BINS append
> plot DATA using (histbin($1)):(1.0) with table
> unset table
> # now plot the data as before
> plot $BINS using 1:2 smooth freq with boxes fill solid border lt -1
That's interesting. Unfortunately I'm using feedgnuplot for this, which
cannot currently use tables. It expects a single "plot" command to do
all the work. Suggestions?
|
|
From: Ethan A M. <me...@uw...> - 2021-07-27 06:17:20
|
On Monday, 26 July 2021 22:56:59 PDT Dima Kogan wrote:
> Ethan A Merritt <me...@uw...> writes:
>
> > Not sure I understand what kind of plot you are aiming for, and you
> > don't give an example of the real data format
>
> Hi. The little example was a close approximation to what I want. If it
> helps, here's what I REALLY want. I have a data file with sorted
> timestamps, one per line, that record the time when something failed. I
> want to make a plot of "failures per hour", as a function of time. So I
> want to consolidate the data into bins, but instead of "with boxes", I'd
> like to plot "with lines". Currently this doesn't work the way I want
> because any hour blocks that have 0 failures in them don't get a y=0
> point in the line plot.
>
>
>
> > but how about initializing all the bins to zero?
> >
> > # initialize a bunch of bins to zero
> > set print $BINS
> > do for [i=1:10] { print i, 0.0 }
> > unset print
> > # add the real data to those same bins
> > set table $BINS append
> > plot DATA using (histbin($1)):(1.0) with table
> > unset table
> > # now plot the data as before
> > plot $BINS using 1:2 smooth freq with boxes fill solid border lt -1
>
> That's interesting. Unfortunately I'm using feedgnuplot for this, which
> cannot currently use tables. It expects a single "plot" command to do
> all the work. Suggestions?
Append a boatload of zero-value timepoints to your data file?
Maybe plot '<cat REALDATA ZEROS' using ...
Teach feedgnuplot to do something more than it does now?
Use another interface that doesn't have that limitation?
For instance, have you tried the gaston front-end to gnuplot in julia?
https://mbaz.github.io/Gaston.jl/v0.10.0/
Ethan
|