Menu

#2845 Windows 6.03: 4 problems with `keyentry`

None
closed-accepted
nobody
None
2025-12-17
2025-12-15
No
  1. gnuplot> ss="'A very long string'"; plot x, keyentry @ss
    warning: ss is not a string variable
  2. gnuplot> ss="'A very long string'"; plot x, keyentry ss
    The string flows beyond the right edge of the screen. Is the space allocated for ss only?
  3. gnuplot> ss="\"A very long string\""; plot x, keyentry @ss
    Likewise.
  4. gnuplot> s="'A very long string'"; plot x, keyentry s
    ^
    unrecognized 'smooth' option

Discussion

  • Ethan Merritt

    Ethan Merritt - 2025-12-15
    • You cannot define and dereference a macro in the same line, since the substitution is done before executing the line and obviously before executing the line the macro is not yet defined. If you split it into two lines there will be no warning or error:
    ss = "'A very long string'"
    plot sinc(x) with lines, \
                    keyentry with points pt 6 title @ss, \
                    keyentry "ABC" title "actual title"
    
    • The issue of space allocation is more complicated. A normal key entry has two parts. The sample line segment/box/point/etc that represents the plot and the text given as a title. When gnuplot is predicting the space needed for key it assumes a fixed width for the plot sample and adds the approximate string length of the title text. A keyentry plot clause also adds two parts to the key. Normally you give a plot style that provides a sample that lines up with other samples in the key and a title that lines up with other titles. If you give a text string in the keyentry instead of a plot style, then that text is placed in the space normally used by the plot sample. A long string probably violates the assumption that all plot samples have the same length. The commands above produce the attached plot.

    • If necessary you can increase the space allocated for the plot sample using the command set key samplen <value>

     
  • Ilya Zakharevich

    Ah, I see that I just forgot how do I typically use keyentry — of course with title.

    But my intent would be naturally much better served with the right modifier (one which you did not show at all, for some reason — but it may be deduced¹⁾ from the docs) — instead of using title! It was not prominent enough in the docs for me to notice…

    ¹⁾ Well, it took a lot of deliberations! I think it makes sense to add a sentence that with “the key on the right”, one should use right alignment of the keyentry to “span the full width of the key”.

    BTW, the docs also say:

    You can use keywords left/right/center for justification, boxed, etc. Example:

    But after all my attempts to scan the docs, I cannot find a single place where all this “etc.” stuff is listed. Maybe add a link to such a place there (and in the other “suitable” places)?

    BTW², in help plot title I do not find the description of modifiers boxed, left etc. being applicable to the provided string. Are they?

     
    • Ethan Merritt

      Ethan Merritt - 2025-12-17

      The extra text (the part not introduced by title) can use any of the properties parsed for labels. See set label. I have added this to the documentation.

       
  • Ethan Merritt

    Ethan Merritt - 2025-12-17
    • status: open --> closed-accepted
    • Group: -->
    • Priority: -->
     

Log in to post a comment.

MongoDB Logo MongoDB