Question

I'm using the plot 'my_image.png' binary filetype=png with rgbimage feature of gnuplot to superimpose images on a (scarce) scatterplot.

My png's have a transparent background, so I had been hoping that they could 'respect' the grid and axes, but unfortunately they are plotted on top of it with a white, opaque background.

Is there any ways to address this issue ?

Minimal working example

The file 2091450.png is provided by First Google result for Transparent PNG :

set terminal pdfcairo font "CMU Serif" linewidth 4 rounded \
fontscale 1.0 size 29.7cm, 21cm enhanced dashed
set output 'transparency_test.pdf'

set style line 81 lt rgb "#808080"
set style line 80 lt 0  # dashed
set style line 80 lt rgb "#808080"  # grey
set grid back linestyle 80

set border 3 back linestyle 81
plot '2091450.png' binary filetype=png origin=(0,0) dx=1.0 dy=1.0 with rgbimage
Was it helpful?

Solution

Several things:

  • Your links gives me only a jpg image despite the URL name (If it would be transparent, you would get only a completely black image as result with the rgbimage style).

  • To plot images with transparency use the rgbalpha plotting style:

    plot 'transparencytest.png' binary filetype=png with rgbalpha
    

    I used the following file transparencytest.png for testing, which works fine:

    enter image description here

  • Why don't you just put the grid and the border to the front layer?

OTHER TIPS

This is a classic case of an answer I couldn't solve initially because of an inappropriate Google search : looking for 'gnuplot png image transparency' was not productive at all, because all the keywords interacts with each others to yield different results.

But a search for 'rgbimage transparency' was much better because of reduced interference between words and led me to this page with the appropriate result :

Instead of using rgbimage, simply use rgbalpha.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top