Menu

#527 add transparency support to palette specification

None
closed-out-of-date
nobody
5
2021-12-22
2021-12-16
No

Hello,

When defining the palette, colors are supported, but we cannot specify some amount of transparency.
This would be very neat in order to visualize crowded plots (where we might want to see
through some of the front/last-plotted lines).

Example:
set palette defined (0 0.0 0.0 0.5, \
1 0.0 0.0 1.0, \
2 0.0 0.5 1.0, \
3 0.0 1.0 1.0, \
4 0.5 1.0 0.5, \
5 1.0 1.0 0.0, \
6 1.0 0.5 0.0, \
7 1.0 0.0 0.0, \
8 0.5 0.0 0.0 )

Those are only RGB triplets (I believe), adding a transparency value is not supported.

There are many cool palettes defined here:
https://github.com/Gnuplotting/gnuplot-palettes

But none using some amount of transparency.
Of course, the user might want to tweak the level of transparency
so that the final result is optimal.

Thanks a lot,
F.

Discussion

  • Ethan Merritt

    Ethan Merritt - 2021-12-16

    Depending on exactly what you need to have in your plot, there are several ways to do this. I will give some examples. If they don't cover exactly what you want, please clarify the requirements.

    Supported for a long time (since version 4.something)
    Full pm3d (palette-color by z value) surface has some amount of transparency

    set style fill transparent solid 0.25
    splot SURFACE using 1:2:3 with pm3d
    

    pm3d surface from data where each point has 7 associated values: x y z R G B Alpha

    color(R,G,B,Alpha) = int(R)<<16 + int(G)<<8 + int(B) + int(Alpha)<<24
    splot SURFACE using 1:2:3:( color($4,$5,$6,$7) ) with pm3d
    

    Supported in current release version (5.4)
    Add transparency from column 4 to palette color in column 3

    splot SURFACE using 1:2:3:(int(palette($4)) + int($5)<<24) with pm3d
    

    Supported in the development version (5.5)
    Define a named palette that includes an alpha component for each palette value

    set colormap MYPALETTE new  # copy current palette into MYPALETTE
    do for [i=1:256] {
        # Take current RGB for this palette entry and add an Alpha
        MYPALETTE[i] = Alpha(i) << 24 + MYPALETTE[i]
    }
    splot SURFACE using 1:2:3 with pm3d fillcolor palette MYPALETTE
    
     
  • Ethan Merritt

    Ethan Merritt - 2021-12-22
    • status: open --> closed-out-of-date
    • Group: -->
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.