Menu

#220 How to set default fill colour?

open
nobody
None
5
2017-05-18
2017-05-16
Peter
No

Not sure if this ranks as a feature request or not but...

How do you set the default fill colour? The 'set style fill' command does not seem to have a field for the fill colour although it does have one for the colour of the border. (In practice, what seems to happen is that the fill colour becomes the border line colour if it is specified.)

This behaviour seems incomplete, especially as the manual suggests "See also 'set style rectangle', which does allow explict setting of the fill colour. Am I missing something?

(I know its possible to specify the fill colour from the data file but this is often not helpful.)

Discussion

  • Ethan Merritt

    Ethan Merritt - 2017-05-17

    The fill color is not part of the fill style. A rectangle has both a fill color and a fill style,
    so "set style rectangle" allows you set both properties. Pieces of a plot (e.g. candlesticks, boxes, fillcurves) apply the fill style to whatever color they would get anyway.

    Does that answer the question?

     
  • Peter

    Peter - 2017-05-17

    "Pieces of a plot (e.g. candlesticks, boxes, fillcurves) apply the fill style to whatever color they would get anyway."

    OK. So what colour would that be? And how do I specify it if I want the boxes filled with pale chartreuse or whatever?

    I think you have told me what the situation seems to be at the moment. What I am raising is that the <fillstyle> specification appears incomplete AFAICS. I am aware that colour is not part of <fillstyle>: I am saying that it should be!

    To make my question clearer. How do I set the fill colour for, say, boxes?

     
  • Ethan Merritt

    Ethan Merritt - 2017-05-17

    set style fill solid 0.5 border lc "black"
    plot $FOO with boxes fillcolor "blue", $BAZ with boxes fillcolor "chartreuse"

     
  • Peter

    Peter - 2017-05-17

    Perfect... and logically what I would have hoped for. But this - as far as I can see - is undocumented (up to manual v5.0.6). On p.100, we have:

    with <style> { {linestyle | ls <line_style>}
    | {{linetype | lt <line_type>}
    {linewidth | lw <line_width>}
    {linecolor | lc <colorspec>}
    {pointtype | pt <point_type>}
    {pointsize | ps <point_size>}
    {fill | fs <fillstyle>}
    {nohidden3d} {nocontours} {nosurface}
    {palette}}
    }

    where <fillstyle> is specified on p.163 as:

    {empty
    | {transparent} solid {<density>}
    | {transparent} pattern {<n>}}
    {border {lt} {lc <colorspec>} | noborder}

    (Note, no mention of colour!)

    So should the 'with' defintion really be:

    with <style> { {linestyle | ls <line_style>}
    | {{linetype | lt <line_type>}
    {linewidth | lw <line_width>}
    {linecolor | lc <colorspec>}
    {pointtype | pt <point_type>}
    {pointsize | ps <point_size>}
    {fillcolor <colorspec>}
    {fill | fs <fillstyle>}
    {nohidden3d} {nocontours} {nosurface}
    {palette}}
    }

    It may also be helpful to spell out this fillcolor setting in the appropriate plot styles from p.47 onwards.

    Thanks for clarifying,

    P

     
  • Ethan Merritt

    Ethan Merritt - 2017-05-17

    It does seem an oversight. OK, we'll add it to the manual.

     
  • Peter

    Peter - 2017-05-18

    Having now looked at this further, another issue! As a MWE,

    set style fill solid 0.5 border lc "black"
    plot sin(x) with fillsteps fillcolor "chartreuse"

    does indeed work. But omitting the "set style fill" line and using

    plot sin(x) with fillsteps fillcolor "chartreuse"

    does not fill the curve. In other words, filling only works if a default fill has been previously set prior to a 'plot command, otherwise not. This seems to run contrary to the manual statement that the characteristics can be set on a per plot element basis. Further, trying:

    plot sin(x) with fillsteps fillcolor "chartreuse" solid

    or indeed appending anything (e.g. "border") to the plot command produces a parsing error. So the suggested amendment I made above to the "with" defintion would seem not to be valid. Given that the 'fillcolor' qualifier to a 'plot' is currently undocumented, not sure where this leaves things. Is this a bug? (Or 'feature deficiency'?)

    Certainly from my point of view, having the 'with' working as I set-out above (with an explicit 'fillcolor' field) would be optimal. But the appending a 'fillcolor' specifier currently seems to terminate parsing of a plot element.

    Grateful for further clarification.

     
    • Ethan Merritt

      Ethan Merritt - 2017-05-18

      I think you may still be conflating fill style and fill color. They really are two separate things.

      The default fill style is "empty". Saying "set style fill solid" changes the default to solid. That default style, whether empty or solid or pattern, is applied to all plot elements that do not specify otherwise.

      To change the fill style for a given plot element or object, use the keyword "fillstyle" (shorthand "fs").
      To change the fill color for a plot element or object, use the keywork "fillcolor" (shorthand "fc").

      The command you show does not work because "solid" is not an independent keyword, it is a modifier for "fillstyle". Like this

      set style data boxes         # this makes the default "with boxes"
      plot A fs solid fc "blue" title "solid blue boxes", \
           B fs transparent solid 0.5 fc "blue" title "see-through boxes", \
           C fs pattern 2 fc "gold" title "golden cage", \
           D fs empty fc variable title "all empty boxes look alike", \
           E fs solid fc variable title "but filled ones can be different"
      
       
  • Peter

    Peter - 2017-05-18

    Sorry. You are right. I am conflating the two. (A consequence of trying use Gnuplot for something rather than simply plot a graph.)

    Thanks.

     

Log in to post a comment.