Menu

#2380 duplicate titles in key

None
closed-fixed
nobody
None
2021-06-02
2020-12-18
Anonymous
No

gnuplot version: gnuplot 5.5 patchlevel 0 (2020-12-18)
system: Arch Linux

steps to reproduce
gnuplot test.plt (with gnuplot version 5.2)
key comprises a single title
gnuplot test.plt (with gnuplot version 5.5)
title gets duplicated according to number of data sets

Is this a new feature or a regression?

1 Attachments

Discussion

  • Ethan Merritt

    Ethan Merritt - 2020-12-19

    Let's call it an unintended consequence of an intended change.

    In versions through 5.2 each plot title was constructed at the time the 'plot' or 'splot' command was issued, prior to reading in any data and certainly prior to plotting anything.

    Starting in version 5.4 the plot title is constructed after the data is read in. This means that the title can contain information derived from the data such as min, max, number of points, and even text that is in the data file. Furthermore, since a single data file can contain multiple data sets it is possible to generate a separate title for each data set in the file. Again this might contain derived information including a text header or at the minimum just an indication of which data set this is.

    Your test case uses an inline data block that contains three data sets separated by two successive blank lines. There is no interesting text associated with each data set but at a minimum we could give each one a separate color and a title that indicates which data set is which:

    splot $data using 1:2:3:-2 with lines lc variable \
                      title sprintf("Data set %g", column(-2))
    

    The result is attached as a plot. This turns out to show a bug (the third reported data set number is off by one) but I hope it also shows why a separate title for each data set might be useful.

    Your test case specifies a constant title string, so all three data sets get that same title. I can see an argument that this is pointless, but it is less clear how or whether the program could avoid it. So far as the current code is concerned the title is being provided by an expression that just happens to consist of a string constant. Perhaps it could distinguish between a string constant and a string-valued function, and generate only a single title in the case of a constant? Hmm. But what about the case of a string variable (as opposed to a string-valued function)? Version 5.4 would allow you to update this string variable during data input, so again it could conceivably make sense to evaluate it separately for each data set. It would be the same string variable each time but the content could change in between successive uses as a title. Tricky.

    I'll think about it some more and would welcome suggestions. I'll also try to fix the off-by-one bug in the value returned by column(-2).

     

    Last edit: Ethan Merritt 2020-12-19
  • Ethan Merritt

    Ethan Merritt - 2020-12-23
    • status: open --> pending-fixed
    • Group: -->
    • Priority: -->
     
  • Karl Ratzsch

    Karl Ratzsch - 2020-12-26

    The new behaviour feels a bit awkward, and doesn't match with the documentation.

    help index says : If index is not specified, the entire file is plotted as a single data set.

    Also "plot" still handles multiple datasets in the old way, i.e. always creates only one entry in the legend.

    I'm thinking the "plot for [] ..." loop should instead accept an open ended iteration specifier [i=0::1], which suppresses the error message if a subsequent index specifer runs out of datasets.

     
    • Ethan Merritt

      Ethan Merritt - 2020-12-26

      By "new behaviour" do you mean the behaviour as reported in the bug or the behaviour after the fix in commit 1ff1f809 (branch-5-4-stable commit a36a3238)?

       
      • Karl Ratzsch

        Karl Ratzsch - 2020-12-26

        Ah, hadn't seen that. Yes, I meant the behaviour reported above.

        I think it was clearly a bug (esp. badly backwards incompatible), but I also agree it would be a useful feature, to be able to plot an arbitrary number of datasets in one go, and each with its own linetype and key entry.

         
  • Ethan Merritt

    Ethan Merritt - 2021-06-02
    • Status: pending-fixed --> closed-fixed
     

Log in to post a comment.