gnuplotalphaalpha-transparency

Gnuplot using both solid and transparent boxes in the same plot with simbolic colour names


I want to plot two sets of data with Gnuplot boxes, where boxes of the first data set are solid while boxes of the second set are transparent.

I see that I can use fillcolor with rgbcolor strings containing alpha information, and that would solve the problem. Is there any way to use colour names instead?

In fact, I need to use boxxyerror rather than boxes, but I suppose that's the same problem as stated above.


Solution

  • You can give a separate fillstyle for each plot component. Here is an example where the same data is plotted twice; the first time with solid fill, the second time (offset) with 25% transparent fill.

    set style data boxxyerror
    plot 'candlesticks.dat' using 1:2:($3/5.):($3/10.):0 fc variable fs solid, \
         '' using ($1+1):($2-1):($3/5.):($3/10.):0 fc variable fs transparent solid 0.25
    

    enter image description here

    As to using color names, can you clarify where you want to specify them? Putting the color name in the plot command is easy. The example above uses the line number (column 0) as input to fc variable to specify the fill color. You could replace that with fc "blue" or fc "red" and so on.

    Reading color names from a file is possible but the best way to do it depends on what version of gnuplot you are using.