#1195 Space reserved in key for plots with no data

closed-works-for-me
nobody
None
5
2012-12-23
2012-12-12
No

This "bug" is demonstrated in the following StackOverflow post:

http://stackoverflow.com/questions/13831981/why-doesnt-the-gnuplot-grid-extend-over-this-whole-plot#comment19055249_13831981

When you plot a data column, but there is no useable data in the the column, gnuplot still reserves space in the key even though it doesn't put a "title" in the key. This behavior changed at some point between gnuplot 4.4.2 and gnuplot 4.6.0 (tested on OS-X). I've also reproduced the "problem" on gnuplot 4.6.1 and gnuplot 4.7.0 on Ubuntu Linux.

Others have said that the plot looks correct using gnuplot 4.4.4 and gnuplot 4.6.1 (Arch-Linux) although as I don't have those systems I can neither confirm nor deny their assertions.

Discussion

  • Matthew Gilson

    Matthew Gilson - 2012-12-12

    Of course, I hope that if you change the behavior on this, you keep the behavior that

    set xrange [0:1]
    set yrange [0:1]
    plot NaN title "foobar"

    will still put something in the key. I've found that trick to be useful to create very customized keys. :-)

     
  • Andrew Rasmussen

    I'm the one who responded to the SO post reporting no problem in 4.6.1 on Arch linux, but that was using a slightly different command than the others (I didn't try to plot the nonexistent columns in the example data). When I try to plot nonexistent data I also get blank space in the key which covers most of the plot.

     
  • Ethan Merritt

    Ethan Merritt - 2012-12-12

    I consider the behavior you describe to be correct. I.e. "not a bug".
    The rationale is that repetitive plots of multiple data files, or of the same data source sampled multiple times, should be consistent. That is, the plot layout and key for all repetitions should be the same even if one of those repetitions has no usable data in a particular column.

    Similarly if you use a mouse click to toggle an individual plotted line on/off, the key entry for that line remains even if the plot itself is currently toggled off.

    As to the StackOverflow thread, Answer 1 correctly points out that the "missing" grid is due to a plot key that supposedly contains 100 entries of which only 2 are non-blank. It is arguably unfortunate that the 2 valid key entries are off-screen due to the ridiculously large number of key entries, but as the plots attached to the thread illustrate, providing non-blank key entries for the 98 missing plots is hardly an improvement.

     
  • Matthew Gilson

    Matthew Gilson - 2012-12-12

    sfeam -- Thanks for the quick response. Feel free to close this ticket in that case. My thoughts behind considering this a "bug" is that there doesn't seem to be any good way in gnuplot to plot as many columns as exist in a datafile -- the easiest way is using iteration with a large enough upper bound. I understand that there is the "valid(N)" function, which you could couple with a `stats` command in a loop to adding columns until a column has no "valid" data. That seems like an awful lot of work for something so simple -- and it seems inefficient, and it fails if you have a column of all text and you're trying to plot numbers.
    Of course, one could use `awk` for this or something of that nature, but it seems to me that something this basic might be worth putting in gnuplot. (or if there is an easier way to do it, I'd love to know :). Anyway, as I said, if this isn't a bug, feel free to close this post. Thanks again for your timely response.

     
  • Ethan Merritt

    Ethan Merritt - 2012-12-12

    There is a very recent option in CVS that implements column(-3) to mean "last column in input file". That addresses the question of how to plot the last column in a file when you don't know how many columns there are, but it doesn't address the question of how to iterate over all of them.

    This option is still EXPERIMENTAL and needs some further polishing. If nothing else, probably `stats $data using -3` should report what that last column turned out to be. Then you could do something like
    stats <datafile> using -3
    plot for [i=1:STATS_lastcolumn] <datafile> using i

     
  • Matthew Gilson

    Matthew Gilson - 2012-12-13

    @sfeam -- Yep, something like that is exactly what I was proposing. Good to know you guys are already working on it. Thanks again and keep up the great work.

     
  • Ethan Merritt

    Ethan Merritt - 2012-12-23

    The stats command now sets a variable:
    STATS_columns
    the reports how many columns of data were found in the first line of the data set.

     
  • Ethan Merritt

    Ethan Merritt - 2012-12-23
    • status: open --> closed-works-for-me
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks