comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: polyfill with transparent colors
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: polyfill with transparent colors [message #60795] Fri, 13 June 2008 13:43 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
cgoethel@igpp.ucla.edu writes:

> I have a linear plot that I would like to draw a polygon on top of,
> but still be able to see the underlying plot. Currently, the polygon
> is drawn on top of the existing plot, but the color is not transparent
> so you cannot see the data that is below the polygon. I cannot draw
> the polygon first and then redraw the plot using oplot (the routine to
> draw the plot is not mine, complex, so can't be modified to use oplot
> rather than plot). Any suggestions?

Here is an article that describes the technique:

http://www.dfanning.com/code_tips/transpoly.html

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: polyfill with transparent colors [message #60798 is a reply to message #60795] Fri, 13 June 2008 12:18 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
cgoethel@igpp.ucla.edu writes:

> I have a linear plot that I would like to draw a polygon on top of,
> but still be able to see the underlying plot. Currently, the polygon
> is drawn on top of the existing plot, but the color is not transparent
> so you cannot see the data that is below the polygon. I cannot draw
> the polygon first and then redraw the plot using oplot (the routine to
> draw the plot is not mine, complex, so can't be modified to use oplot
> rather than plot). Any suggestions?

Roll your own alpha channel image. Here is an example
of how you can do it. You will need a couple of Coyote
Library programs to run the code:

http://www.dfanning.com/programs/coyoteprograms.zip

Cheers,

David

;----------------------------------------------------------- -------
PRO Transparent_Polygon

; Create some data.
signal = LoadData(1)
time = Findgen(N_Elements(signal)) * 6.0 / N_Elements(signal)

; Create some windows.
Window, Title='Data Window', XSIZE=400, YSIZE=400, /FREE
dataWin = !D.Window
Window, XSIZE=400, YSIZE=400, /FREE, /PIXMAP
pixmapWin = !D.Window

; Draw plot in data window.
WSet, dataWin
Plot, time, signal, BACKGROUND=FSC_Color('ivory'), $
COLOR=FSC_Color('navy'), $
/NODATA, XTitle='Time', YTitle='Signal Strength'
OPLOT, time, signal, THICK=2, COLOR=FSC_Color('cornflower blue')
OPLOT, time, signal, PSYM=2, COLOR=FSC_Color('olive')

; Take a snapshot.
win1 = TVREAD(TRUE=3)

; Copy data window and draw a polygon in the pixmap window.
WSet, pixmapWin
DEVICE, COPY=[0,0,400, 400, 0, 0, dataWin]
POLYFILL, [0.3, 0.65, 0.5, 0.25, 0.30], $
[0.27, 0.32, 0.75, 0.62, 0.27], /NORMAL, $
COLOR=FSC_COLOR('deep pink')

; Take a snapshot of this window, then delete it.
win2 = TVREAD(TRUE=3)
WDelete, pixmapWin

; Use a half-transparent alpha.
alpha = 0.5
Window, Title='Transparent Window', XSIZE=400, YSIZE=400, /FREE
TV, (win2 * alpha) + (1 - alpha) * win1, TRUE=3

END
;----------------------------------------------------------- -------

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: polyfill with transparent colors [message #60833 is a reply to message #60798] Fri, 20 June 2008 08:42 Go to previous messageGo to next message
Mike[2] is currently offline  Mike[2]
Messages: 99
Registered: December 2005
Member
On Jun 13, 3:18 pm, David Fanning <n...@dfanning.com> wrote:

> Roll your own alpha channel image.

Here's a similar thing I wrote a while back to add color washes to
ROIs drawn on images. As with all codes that don't reinvent too many
wheels, it relies on the Coyote Library too :-)

http://mypage.iu.edu/~mmiller3/IDL/polywash.html

Mike
Re: polyfill with transparent colors [message #61041 is a reply to message #60833] Thu, 26 June 2008 20:12 Go to previous message
Richard French is currently offline  Richard French
Messages: 173
Registered: December 2000
Senior Member
On 6/20/08 11:42 AM, in article
0dad533c-5574-4ad8-8ad1-e34c442ae17a@c65g2000hsa.googlegroups.com, "Mike"
<Michael.Miller5@gmail.com> wrote:

> On Jun 13, 3:18 pm, David Fanning <n...@dfanning.com> wrote:
>
>> Roll your own alpha channel image.
>
> Here's a similar thing I wrote a while back to add color washes to
> ROIs drawn on images. As with all codes that don't reinvent too many
> wheels, it relies on the Coyote Library too :-)
>
> http://mypage.iu.edu/~mmiller3/IDL/polywash.html
>
> Mike

Mike - your posted version of polywash.pro does not have the BACKGROUND
keyword present in the definition line for the procedure.

Dick
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: How to make the figure change automatically while I selected a new color table?
Next Topic: The problem about the '.RESET_SESSION' command

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:03:52 PDT 2025

Total time taken to generate the page: 0.00502 seconds