#1261 Key bug adds rows to key when no title provided

None
open
nobody
None
5
2013-07-08
2013-05-01
Jason G.
No

I found a bug where white space is added to the key when multiple histogram plots are done. White space is added to the key when titles for the plots have not titles. Included below is the fix.

--- ./orig/gnuplot-4.6.3/src/graphics.c 2013-04-08 12:47:57.000000000 -0400
+++ gnuplot-4.6.3/src/graphics.c 2013-04-29 11:23:50.909797064 -0400
@@ -231,7 +231,8 @@
/ Check for new histogram here and save space for divider /
if (this_plot->plot_style == HISTOGRAMS
&& previous_plot_style == HISTOGRAMS
- && this_plot->histogram_sequence == 0 && cnt > 1)
+ && this_plot->histogram_sequence == 0 && cnt > 1
+ && !this_plot->title_is_suppressed)
cnt++;
/ Check for column-stacked histogram with key entries /
if (this_plot->plot_style == HISTOGRAMS && this_plot->labels) {

Discussion

  • Ethan Merritt
    Ethan Merritt
    2013-06-27

    If I understand the bug report correctly, then the change you propose is not a correct fix. I take it you are suggesting that if no member of a histogram cluster has a title, then the blank lines that normally come before and after the title entries for that cluster should be collapsed into a single blank line. That may be so, but in order to test of this case you'd have to track how many members of the previous histogram had titles. It is not sufficient to test whether the first member of the next histogram has a title.

    If I am misunderstanding the bug report, please provide a script that shows an example of the problem.

    If I understand correctly and you want to submit a revised patch, I would be happy to look at it.

       Ethan
    
     
  • Jason G.
    Jason G.
    2013-06-27

    Hi Ethan,

    As far as I remember, the bug adds a blank line to the key for each cluster
    to separate clusters in the key. However when no cluster title is provided,
    the space is still added and it makes the key look screwed up.

    Basically, the code (as I remember) counts how many horizontal lines need
    to be in the key. The fix checks to see if the title is not suppressed
    before adding an extra empty row. This fixed the issue for me and I saw
    other people post online they had similar problems so I just thought I'd
    submit my fix (since its only one line).

    Thanks,

    Jason

    On Thu, Jun 27, 2013 at 4:46 PM, Ethan Merritt sfeam@users.sf.net wrote:

    If I understand the bug report correctly, then the change you propose is
    not a correct fix. I take it you are suggesting that if no member of a
    histogram cluster has a title, then the blank lines that normally come
    before and after the title entries for that cluster should be collapsed
    into a single blank line. That may be so, but in order to test of this case
    you'd have to track how many members of the previous histogram had titles.
    It is not sufficient to test whether the first member of the next histogram
    has a title.

    If I am misunderstanding the bug report, please provide a script that
    shows an example of the problem.

    If I understand correctly and you want to submit a revised patch, I would
    be happy to look at it.

    Ethan


    Status: open
    Created: Wed May 01, 2013 07:47 PM UTC by Jason G.
    Last Updated: Wed May 01, 2013 07:47 PM UTC
    Owner: nobody

    I found a bug where white space is added to the key when multiple
    histogram plots are done. White space is added to the key when titles for
    the plots have not titles. Included below is the fix.

    --- ./orig/gnuplot-4.6.3/src/graphics.c 2013-04-08 12:47:57.000000000 -0400
    +++ gnuplot-4.6.3/src/graphics.c 2013-04-29 11:23:50.909797064 -0400
    @@ -231,7 +231,8 @@
    / Check for new histogram here and save space for divider /
    if (this_plot->plot_style == HISTOGRAMS
    && previous_plot_style == HISTOGRAMS
    - && this_plot->histogram_sequence == 0 && cnt > 1)
    + && this_plot->histogram_sequence == 0 && cnt > 1
    + && !this_plot->title_is_suppressed)
    cnt++;
    / Check for column-stacked histogram with key entries /
    if (this_plot->plot_style == HISTOGRAMS && this_plot->labels) {
    ------------------------------

    Sent from sourceforge.net because you indicated interest in
    https://sourceforge.net/p/gnuplot/patches/619/

    To unsubscribe from further messages, please visit
    https://sourceforge.net/auth/subscriptions/

    --
    Jason Gionta
    Cyber Defense Lab
    North Carolina State University
    jjgionta@ncsu.edu

     
  • Ethan Merritt
    Ethan Merritt
    2013-06-27

    As far as I remember, the bug adds a blank line to the key for each cluster to separate clusters in the key.

    Correct.

    However when no cluster title is provided, the space is still added and it makes the key look screwed up.

    No. The cluster title is printed below the plot, not in the key. The spacing in the key is (or should not be) affected by the presence or absence of a cluster title.

    Basically, the code (as I remember) counts how many horizontal lines need to be in the key. The fix checks to see if the title is not suppressed before adding an extra empty row.

    I agree that would fix it, but there is no such counting code in your patch.

    This fixed the issue for me and I saw other people post online they had similar problems so I just thought I'd submit my fix.

    So far as I can see, this patch would only fix the case of a single member in a cluster (which I think is an unusual case). But I could be wrong, which is why I asked for an example of the problem so that I could better understand how/why the patch fixed it.

     
  • Ethan Merritt
    Ethan Merritt
    2013-06-27

    [blech. I hate this interface for typing]
    I meant "the spacing in the key is not (or should not be) affected by the presence or absence of a cluster title.

     
  • Jason G.
    Jason G.
    2013-06-27

    I was seeing the spacing in the key being affected.

    Test data. Create data files f1.data and f2.data

    data file 1 - f1.data
    "Title" "Percent 1" "Percent 2"
    Type1 87.896832 12.103168

    data file 2 - f2.data
    "Title" "Percent 1" "Percent 2"
    Type2 73.676931 26.323069
    Type3 73.983282 26.016718
    Type1 26.836433

    plotfile:
    set title "Percentages"
    set ylabel "Pecentage of Data"
    set yrange [0:100]
    set terminal postscript color
    set output "test.ps"
    set style data histogram
    set style histogram rowstacked gap 1
    set style fill solid border -1

    set boxwidth .5
    set key autotitle columnheader
    set xtics rotate by -45

    plot newhistogram "1" lt 1, "f1.data" u 2:xtic(1) title 'P1', '' using 3
    title 'P2', \ newhistogram "2" lt 1, "f2.data" u 2:xtic(1) notitle, '' using 3 notitle

    On Thu, Jun 27, 2013 at 6:02 PM, Ethan Merritt sfeam@users.sf.net wrote:

    [blech. I hate this interface for typing]
    I meant "the spacing in the key is not (or should not be) affected by
    the presence or absence of a cluster title.


    Status: open
    Created: Wed May 01, 2013 07:47 PM UTC by Jason G.
    Last Updated: Thu Jun 27, 2013 10:00 PM UTC
    Owner: nobody

    I found a bug where white space is added to the key when multiple
    histogram plots are done. White space is added to the key when titles for
    the plots have not titles. Included below is the fix.

    --- ./orig/gnuplot-4.6.3/src/graphics.c 2013-04-08 12:47:57.000000000 -0400
    +++ gnuplot-4.6.3/src/graphics.c 2013-04-29 11:23:50.909797064 -0400
    @@ -231,7 +231,8 @@
    / Check for new histogram here and save space for divider /
    if (this_plot->plot_style == HISTOGRAMS
    && previous_plot_style == HISTOGRAMS
    - && this_plot->histogram_sequence == 0 && cnt > 1)
    + && this_plot->histogram_sequence == 0 && cnt > 1
    + && !this_plot->title_is_suppressed)
    cnt++;
    / Check for column-stacked histogram with key entries /
    if (this_plot->plot_style == HISTOGRAMS && this_plot->labels) {
    ------------------------------

    Sent from sourceforge.net because you indicated interest in
    https://sourceforge.net/p/gnuplot/patches/619/

    To unsubscribe from further messages, please visit
    https://sourceforge.net/auth/subscriptions/

    --
    Jason Gionta
    Cyber Defense Lab
    North Carolina State University
    jjgionta@ncsu.edu

     
  • Ethan Merritt
    Ethan Merritt
    2013-06-27

    Is it possible that you left out a command "set key box" in that test script?

    Without a box around the key, I don't see any obvious error in the key for any of versions 4.6.1 through current cvs.

    With "set key box", I see extra space at the bottom of the key. If that is the bug you meant, I totally misunderstood. I though you were talking about spacing between the key entries, not the size of the box. I'll have a look. If I'm still misunderstanding, please tell me what I'm supposed to look for in the output of your test script.

     
  • Jason G.
    Jason G.
    2013-06-27

    You are correct, thanks for reminding me. "set key box" should be there.
    you can see the space at the bottom key. The more clusters you have the
    more blank spaces there are.

    On Thu, Jun 27, 2013 at 7:03 PM, Ethan Merritt sfeam@users.sf.net wrote:

    Is it possible that you left out a command "set key box" in that test
    script?

    Without a box around the key, I don't see any obvious error in the key for
    any of versions 4.6.1 through current cvs.

    With "set key box", I see extra space at the bottom of the key. If that is
    the bug you meant, I totally misunderstood. I though you were talking about
    spacing between the key entries, not the size of the box. I'll have a look.
    If I'm still misunderstanding, please tell me what I'm supposed to look for
    in the output of your test script.


    Status: open
    Created: Wed May 01, 2013 07:47 PM UTC by Jason G.
    Last Updated: Thu Jun 27, 2013 10:02 PM UTC
    Owner: nobody

    I found a bug where white space is added to the key when multiple
    histogram plots are done. White space is added to the key when titles for
    the plots have not titles. Included below is the fix.

    --- ./orig/gnuplot-4.6.3/src/graphics.c 2013-04-08 12:47:57.000000000 -0400
    +++ gnuplot-4.6.3/src/graphics.c 2013-04-29 11:23:50.909797064 -0400
    @@ -231,7 +231,8 @@
    / Check for new histogram here and save space for divider /
    if (this_plot->plot_style == HISTOGRAMS
    && previous_plot_style == HISTOGRAMS
    - && this_plot->histogram_sequence == 0 && cnt > 1)
    + && this_plot->histogram_sequence == 0 && cnt > 1
    + && !this_plot->title_is_suppressed)
    cnt++;
    / Check for column-stacked histogram with key entries /
    if (this_plot->plot_style == HISTOGRAMS && this_plot->labels) {
    ------------------------------

    Sent from sourceforge.net because you indicated interest in
    https://sourceforge.net/p/gnuplot/patches/619/

    To unsubscribe from further messages, please visit
    https://sourceforge.net/auth/subscriptions/

    --
    Jason Gionta
    Cyber Defense Lab
    North Carolina State University
    jjgionta@ncsu.edu

     
  • Ethan Merritt
    Ethan Merritt
    2013-07-08

    Ticket moved from /p/gnuplot/patches/619/