gnuplot 6.0.0
Linux alex 6.11.0-21-generic #21~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Feb 24 16:52:15 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
This works as expected:
plot 'box.txt' using (1):2:(0.5):('A') index 0 every :::0::0 with boxplot
This does not put the label B on the x axis.
plot 'box.txt' using (1):2:(0.5):('B') index 0 every :::1::1 with boxplot
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
I can't diagnose this for certain without a copy of your data file 'box.txt'. Can you attach it here?
In case it helps, let me try to clarify what command you show implies about the data file. The fourth field in the
usingspecifier refers to a column in the input file. In your first command you have asked it to look for category strings in a column of the input file with columnheader "A". In the second command you have asked it to look for category strings in a column with columnheader "B". Is that how your input file is structured?I'm not the original poster, but I was able to reproduce the issue.
In the following script:
Label "A" is placed correctly, but label "B" is placed at x = -999 instead of its expected position. This can be confirmed by setting "xrange [-1000:3]".
This happens because when using "every :::1::1", the first element in
plot->pointsis a blank line, andplot->points[0].xis -999. Similarly, in the case of "every :::2::2", the first two elements are stored as blank lines, and for "every :::3::3", the first three elements become blank lines. These blank lines are assigned the point type UNDEFINED. However, since "add_tics_boxplot_factors()" does not detect whether the first element is UNDEFINED, it mistakenly assigns the x-axis value of -999, which causes the function to fail.The attached patch works around this by:
- Using the explicit x value passed to "check_or_add_boxplot_factor()" for
new_label->place.x.- Referring to
label->place.xinstead ofplot->points->xin "add_tics_boxplot_factors()".With this change, labels are drawn at the correct positions even when using "every" with boxplots data.
Huh. I see what your patch is doing, but I am not sure that is really the issue here. It depends on what the original poster was actually aiming for.
The fourth field of the boxplot "using" specifier is intended to be a column identifier, not a label. Are you assuming the original intent was this command?
That indeed uncovers a bug, which can be worked around by using instead
That bug is a curious one that only affected 4-column boxplots with tic labels. Fixed now..
Your patch addresses a different case that may or may not be closer to the original intent. See test cases below. I have added your fix also (with a minor change to make the C compiler happy).
Actually, I had assumed that the original poster's syntax should work as intended. This is because the "help boxplot" documentation contains the following description regarding x-axis labels:
While the latter part of the documentation mentions that the fourth field can also act as a column selector, the straightforward reading of the sentence above suggests that in the four-column syntax, the label is expected to be a string provided directly in the fourth column—not specified via
xticlabel.In fact, when not using
every, the syntax with a string label in the fourth column does behave that way.Also, commit
8a06321e826b6a89b3d0468e8d4e314575d66ab8says:This implies that the syntax used by the original poster is also considered valid, or at least acceptable.
In any case, it's hard to be certain without seeing the contents of 'box.txt'. That would help clarify what the intended syntax was and whether the fourth field was meant to be a label or a column index.
I took the intended meaning of the documentation sentence you quote to be
But I can totally see how providing a string constant in parentheses would seem like it would substitute for a real fourth column just the way providing a numerical constant in parentheses substitutes for numerical values in a real data column.
Anyhow, that's two fixes for two real bugs. Hopefully one or the other solves the original problem.
Your explanation really cleared things up for me. In a plot command such as:
the fourth column,
("A"), can be interpreted as indicating that every record belongs to the category (or factor) "A".I hope so too.