dkogan / feedgnuplot

Tool to plot realtime and stored data from the commandline, using gnuplot.
Other
707 stars 37 forks source link

Plotting both regular and cumulative histogram (from the same data) on the same graph #35

Closed aktau closed 6 years ago

aktau commented 6 years ago

This is often done in papers and I'd like to do the same. Is it possible with feedgnuplot or do I have to go for manual gnuplot scripts? Reading the man page makes me think it cannot be done currently. I could think of a hack to pass the dataset twice, but the histstyle argument does not allow choosing a specific curve to render AFAIK. Thanks.

dkogan commented 6 years ago

On June 24, 2018 4:10:58 PM PDT, Nicolas Hillegeer notifications@github.com wrote:

This is often done in papers and I'd like to do the same. Is it possible with feedgnuplot or do I have to go for manual gnuplot scripts? Reading the man page makes me think it cannot be done currently. I could think of a hack to pass the dataset twice, but the histstyle argument does not allow choosing a specific curve to render AFAIK. Thanks.

Hi. I've never had this need, and you're the first one to ask. I want to say there's no nice way to do this currently. In the near term, if you speak perl, you should be able to hack in something without a lot of work. In the longer term, I can add something, but won't get to it for a few weeks.

aktau commented 6 years ago

No problem at all, I'm sure this is pretty fringe. If adding this feature is just difficult from the point-of-view of constructing a command-line, I'd be happy not having it either. What I'm planning to do is to see what feedgnuplot(1) produces for both types of histograms, and manually create a gnuplot script that contains both. Then I just:

  { 
    echo "gnuplot script
               plot '-' ..." 
    data-generating-script
    echo "e"
  } | gnuplot

Which is a bit ugly, but works :). Thanks for considering it!

dkogan commented 6 years ago

Actually, now that I think of it, a better temporary hack is to use --equation. That just adds the string to the plot command verbatim. You can specify one histogram normally and the other with --equation. I'll see about doing better in a few weeks.

dkogan commented 6 years ago

Hi. I just looked at this, and unfortunately, it's fairly painful to make this work without breaking the existing api. You can hack it with something like this:

seq 500 | awk '{print $1*$1,$1*$1}' | feedgnuplot --style 1 'using (histbin2($2)):(1.0) smooth cnormal  with lines' --binwidth 10000 --extracmds 'histbin2(x) = 100 * floor(0.5 + x/100)' --y2 1 --histo 0

So you duplicate the data, define another histbin function (with a higher resolution), and explicitly set the style. AND you need to modify the sources to not print "notitle". And even then, the histogram bars end up being plotted on top of the cumulative line.

I'm sorry, but I can't do this in a reasonable way. If I hear multiple other users request this feature, maybe I'll think about it again, but I just can't figure out how to do this right now.

aktau commented 6 years ago

Hi Dima,

No worries, as someone who's designed CLIs before (admittedly less full-featured than feedgnuplot), I can feel the pain of trying to cater to all use cases. Sometimes it's best to say no.

However, I'm very glad for the alternate suggestion, that would've taken me a lot of time to come up with myself.