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

Home » Public Forums » archive » Re: Color background with PLOT
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: Color background with PLOT [message #51430] Sat, 18 November 2006 17:00
Jeff Hester is currently offline  Jeff Hester
Messages: 21
Registered: December 2001
Junior Member
David Fanning wrote:

> Matt Harner writes:
>
>
>> I'd like to have a color background on a plot using direct graphics.
>> Instead of the built in background using the BACKGROUND keyword to
>> PLOT, I'd like the background to only be behind the plotted data, not
>> the entire window (axis, ticks, title, etc). The only way I have found
>> to do this is to draw a colored box with POLYFILL in the area that I
>> desire, but then the axis tick marks are under the polygon. Is there
>> any way to do this while still maintaining the plot tick marks?
>
>
> If you position your plot with the POSITION keyword, then
> you can draw your background polygon first into that position,
> then draw your plot with the NOERASE keyword set. (You might
> have to erase the window first with the ERASE command. This
> would be a good time to get the area outside the polygon
> the color you want, since you can use the COLOR keyword
> here as well.)
>
> Direct graphics commands just put pixels on top of pixels,
> so sometimes you have to "layer" your graphics commands
> to achieve the results you want. The NOERASE keyword is
> a great help when you are re-drawing axis tick marks and
> the like. :-)
>
> Erase, COLOR=FSC_COLOR('ivory')
> p = [0.15, 0.15, 0.9, 0.9]
> PolyFill, [p[0],p[0],p[2],p[2],p[0]], $
> [p[1],p[3],p[3],p[1],p[1]], $
> COLOR=FSC_COLOR('sky blue'), /NORMAL
> Plot, findgen(11), COLOR=FSC_COLOR('red'), $
> POSITION=p, /NOERASE
>
> Cheers,
>
> David

Or you can be exquisitely inelegant and draw your axes with
plot,/nodata, do the polyfill using data coordinates, then do your plot
with plot,/noerase.

For various reasons (like inertia) I mostly use direct graphics, so
frequently redo things in a plotting sequence to get the layering right.

Cheers,
Jeff
Re: Color background with PLOT [message #51435 is a reply to message #51430] Sat, 18 November 2006 12:02 Go to previous message
Matt Harner is currently offline  Matt Harner
Messages: 5
Registered: September 2006
Junior Member
Thanks Dave - This is exactly what I needed.

Matt
Re: Color background with PLOT [message #51436 is a reply to message #51435] Sat, 18 November 2006 09:32 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Matt Harner writes:

> I'd like to have a color background on a plot using direct graphics.
> Instead of the built in background using the BACKGROUND keyword to
> PLOT, I'd like the background to only be behind the plotted data, not
> the entire window (axis, ticks, title, etc). The only way I have found
> to do this is to draw a colored box with POLYFILL in the area that I
> desire, but then the axis tick marks are under the polygon. Is there
> any way to do this while still maintaining the plot tick marks?

If you position your plot with the POSITION keyword, then
you can draw your background polygon first into that position,
then draw your plot with the NOERASE keyword set. (You might
have to erase the window first with the ERASE command. This
would be a good time to get the area outside the polygon
the color you want, since you can use the COLOR keyword
here as well.)

Direct graphics commands just put pixels on top of pixels,
so sometimes you have to "layer" your graphics commands
to achieve the results you want. The NOERASE keyword is
a great help when you are re-drawing axis tick marks and
the like. :-)

Erase, COLOR=FSC_COLOR('ivory')
p = [0.15, 0.15, 0.9, 0.9]
PolyFill, [p[0],p[0],p[2],p[2],p[0]], $
[p[1],p[3],p[3],p[1],p[1]], $
COLOR=FSC_COLOR('sky blue'), /NORMAL
Plot, findgen(11), COLOR=FSC_COLOR('red'), $
POSITION=p, /NOERASE

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.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Image warping in IDL
Next Topic: Issue with 6.3, Mac OS X 10.4, 3 displays, X11

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

Current Time: Wed Oct 08 19:43:41 PDT 2025

Total time taken to generate the page: 0.00378 seconds