1

I want to plot a filled circle in Gnuplot, but with transparency changing with the distance to the center of the circle, i.e. a transparency gradient (solid near to the center, and transparent near to the radius of circle).

I want something like this

Is there any way of doing this in Gnuplot?

Thank you in advance!

2 Answers2

0

One option would be to define a custom function describing the gradient (e.g., a Gaussian) and then use pm3d map to visualize it:

set terminal pngcairo size 400,400
set output 'fig.png'

unset border
unset colorbox
unset xtics
unset ytics

set pm3d map

#force the plot to occupy the entire canvas
set lmargin at screen 0
set rmargin at screen 1
set tmargin at screen 1
set bmargin at screen 0

set isosamples 100,100

#specify custom palette
set palette model RGB
set palette defined ( 0 "white", 1 "royalblue" )

set xr [-10:10]
set yr [-10:10]

#a Gaussian might be a reasonable choice
splot exp(-0.2*(x*x+y*y))

This then produces:

enter image description here

Another choice of the defining function might be:

set xr [-pi:pi]
set yr [-pi:pi]
fn(r) = (r>(pi/2))?0:(cos(r))
splot fn(sqrt(x*x+y*y))

This yields:

enter image description here

ewcz
  • 12,819
  • 1
  • 25
  • 47
0

Try this:

set xrange [0:10]
set yrange [0:10]
do for [i=1:100] {
set style fill transparent solid i/100. noborder
set object circle at 5,5 radius 1.-i/100. fc rgb 'blue'
}
plot -1

enter image description here

Not all terminals support transparency; see help transparent. I made this with the terminal x11.

Michael
  • 5,095
  • 2
  • 13
  • 35