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

Home » Public Forums » archive » Filling the frame of a NG 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
Filling the frame of a NG plot [message #89781] Wed, 03 December 2014 08:43 Go to next message
dg86 is currently offline  dg86
Messages: 118
Registered: September 2012
Senior Member
Dear Folks,

I'd like to fill the plot area of a New Graphics plot with a solid color.
So far, I haven't found a way to do this that does not blank out the plot
itself. Here's a stripped-down example that is supposed to plot a diagonal
line over a yellow background. The yellow polygon, however, covers up the
diagonal line.

win = window(dimensions = [512, 512])
pos = [0.2, 0.2, 0.8, 0.8]
ndx = [[0, 1], [2, 1], [2, 3], [0, 3], [0, 1]]
verts = pos[ndx]
poly = polygon(verts, /fill_background, fill_color = 'yellow', $
fill_transparency = 0, target = win)
pl = plot([0, 1], position = pos, current = win)

I tried moving the polygon to the back with
poly.order, /send_to_back
and moving the plot to the front with
pl.order, /bring_to_front
Neither works.

> print,!version
{ x86_64 darwin unix Mac OS X 8.4 Sep 27 2014 64 64}

What's the right way to do what I want?

All the best,

David
Re: Filling the frame of a NG plot [message #89782 is a reply to message #89781] Wed, 03 December 2014 09:40 Go to previous messageGo to next message
chris_torrence@NOSPAM is currently offline  chris_torrence@NOSPAM
Messages: 528
Registered: March 2007
Senior Member
On Wednesday, December 3, 2014 9:43:57 AM UTC-7, David Grier wrote:
> Dear Folks,
>
> I'd like to fill the plot area of a New Graphics plot with a solid color.
> So far, I haven't found a way to do this that does not blank out the plot
> itself. Here's a stripped-down example that is supposed to plot a diagonal
> line over a yellow background. The yellow polygon, however, covers up the
> diagonal line.
>
> win = window(dimensions = [512, 512])
> pos = [0.2, 0.2, 0.8, 0.8]
> ndx = [[0, 1], [2, 1], [2, 3], [0, 3], [0, 1]]
> verts = pos[ndx]
> poly = polygon(verts, /fill_background, fill_color = 'yellow', $
> fill_transparency = 0, target = win)
> pl = plot([0, 1], position = pos, current = win)
>
> I tried moving the polygon to the back with
> poly.order, /send_to_back
> and moving the plot to the front with
> pl.order, /bring_to_front
> Neither works.
>
>> print,!version
> { x86_64 darwin unix Mac OS X 8.4 Sep 27 2014 64 64}
>
> What's the right way to do what I want?
>
> All the best,
>
> David

Hi David,

Have you tried the BACKGROUND_COLOR property?

p = PLOT(/TEST, BACKGROUND_COLOR='yellow')

-Chris
Re: Filling the frame of a NG plot [message #89783 is a reply to message #89782] Wed, 03 December 2014 09:57 Go to previous messageGo to next message
dg86 is currently offline  dg86
Messages: 118
Registered: September 2012
Senior Member
On Wednesday, December 3, 2014 12:41:41 PM UTC-5, Chris Torrence wrote:
> On Wednesday, December 3, 2014 9:43:57 AM UTC-7, David Grier wrote:
>> Dear Folks,
>>
>> I'd like to fill the plot area of a New Graphics plot with a solid color.
>> So far, I haven't found a way to do this that does not blank out the plot
>> itself. Here's a stripped-down example that is supposed to plot a diagonal
>> line over a yellow background. The yellow polygon, however, covers up the
>> diagonal line.
>>
>> win = window(dimensions = [512, 512])
>> pos = [0.2, 0.2, 0.8, 0.8]
>> ndx = [[0, 1], [2, 1], [2, 3], [0, 3], [0, 1]]
>> verts = pos[ndx]
>> poly = polygon(verts, /fill_background, fill_color = 'yellow', $
>> fill_transparency = 0, target = win)
>> pl = plot([0, 1], position = pos, current = win)
>>
>> I tried moving the polygon to the back with
>> poly.order, /send_to_back
>> and moving the plot to the front with
>> pl.order, /bring_to_front
>> Neither works.
>>
>>> print,!version
>> { x86_64 darwin unix Mac OS X 8.4 Sep 27 2014 64 64}
>>
>> What's the right way to do what I want?
>>
>> All the best,
>>
>> David
>
> Hi David,
>
> Have you tried the BACKGROUND_COLOR property?
>
> p = PLOT(/TEST, BACKGROUND_COLOR='yellow')
>
> -Chris

Dear Chris,

Thanks for your suggestion.
The straightforward solution works for simple cases, but not if I try to place
a plot over an image. Here's an example:

win = window(dimensions = [512, 512])
im = image(randomu(seed, [512, 512]), position = [0, 0, 1, 1], current = win)
pl = plot([0, 1], position = pos, current = win, background_color = 'yellow')

The intention here is to superimpose a plot with a yellow background over a field
of grayscale noise. The plot appears over the noise, but without the yellow
background. That's why I started trying to use a polygon to fill in the frame.

Is this a bug?

TTFN,

David
Re: Filling the frame of a NG plot [message #89784 is a reply to message #89783] Wed, 03 December 2014 09:59 Go to previous messageGo to next message
dg86 is currently offline  dg86
Messages: 118
Registered: September 2012
Senior Member
On Wednesday, December 3, 2014 12:57:59 PM UTC-5, David Grier wrote:
> On Wednesday, December 3, 2014 12:41:41 PM UTC-5, Chris Torrence wrote:
>> On Wednesday, December 3, 2014 9:43:57 AM UTC-7, David Grier wrote:
>>> Dear Folks,
>>>
>>> I'd like to fill the plot area of a New Graphics plot with a solid color.
>>> So far, I haven't found a way to do this that does not blank out the plot
>>> itself. Here's a stripped-down example that is supposed to plot a diagonal
>>> line over a yellow background. The yellow polygon, however, covers up the
>>> diagonal line.
>>>
>>> win = window(dimensions = [512, 512])
>>> pos = [0.2, 0.2, 0.8, 0.8]
>>> ndx = [[0, 1], [2, 1], [2, 3], [0, 3], [0, 1]]
>>> verts = pos[ndx]
>>> poly = polygon(verts, /fill_background, fill_color = 'yellow', $
>>> fill_transparency = 0, target = win)
>>> pl = plot([0, 1], position = pos, current = win)
>>>
>>> I tried moving the polygon to the back with
>>> poly.order, /send_to_back
>>> and moving the plot to the front with
>>> pl.order, /bring_to_front
>>> Neither works.
>>>
>>>> print,!version
>>> { x86_64 darwin unix Mac OS X 8.4 Sep 27 2014 64 64}
>>>
>>> What's the right way to do what I want?
>>>
>>> All the best,
>>>
>>> David
>>
>> Hi David,
>>
>> Have you tried the BACKGROUND_COLOR property?
>>
>> p = PLOT(/TEST, BACKGROUND_COLOR='yellow')
>>
>> -Chris
>
> Dear Chris,
>
> Thanks for your suggestion.
> The straightforward solution works for simple cases, but not if I try to place
> a plot over an image. Here's an example:
>
> win = window(dimensions = [512, 512])
> im = image(randomu(seed, [512, 512]), position = [0, 0, 1, 1], current = win)
> pl = plot([0, 1], position = pos, current = win, background_color = 'yellow')
>
> The intention here is to superimpose a plot with a yellow background over a field
> of grayscale noise. The plot appears over the noise, but without the yellow
> background. That's why I started trying to use a polygon to fill in the frame.
>
> Is this a bug?
>
> TTFN,
>
> David

Oops: I forgot the position keyword:

pos = [0.2,0.2,0.8,0.8]

TTFN,

David
Re: Filling the frame of a NG plot [message #89785 is a reply to message #89784] Wed, 03 December 2014 10:19 Go to previous messageGo to next message
chris_torrence@NOSPAM is currently offline  chris_torrence@NOSPAM
Messages: 528
Registered: March 2007
Senior Member
I think it always tries to keep "annotations" (like Polygons, Text, etc.) on top of the "visualizations" (like Plots, etc). One possibility is to use POLYGON with the /DATA keyword, so it throws it into the Visualization space instead of Annotation space.

However, a better way might be to do a fake plot with FILL_BACKGROUND:

pos = [0.2,0.2,0.8,0.8]
win = window(dimensions = [512, 512])
im = image(randomu(seed, [512, 512]), position = [0, 0, 1, 1], current = win)
pl = plot([0, 0, 1, 1], [0, 1, 1, 0], position=pos, current=win, $
/fill_background, fill_color = 'yellow', fill_level=0, $
axis_style=0, linestyle='none')
p2 = plot([0, 1], position = pos, current = win)

-Chris
Re: Filling the frame of a NG plot [message #89796 is a reply to message #89785] Wed, 03 December 2014 14:11 Go to previous message
dg86 is currently offline  dg86
Messages: 118
Registered: September 2012
Senior Member
On Wednesday, December 3, 2014 1:19:26 PM UTC-5, Chris Torrence wrote:
> I think it always tries to keep "annotations" (like Polygons, Text, etc.) on top of the "visualizations" (like Plots, etc). One possibility is to use POLYGON with the /DATA keyword, so it throws it into the Visualization space instead of Annotation space.
>
> However, a better way might be to do a fake plot with FILL_BACKGROUND:
>
> pos = [0.2,0.2,0.8,0.8]
> win = window(dimensions = [512, 512])
> im = image(randomu(seed, [512, 512]), position = [0, 0, 1, 1], current = win)
> pl = plot([0, 0, 1, 1], [0, 1, 1, 0], position=pos, current=win, $
> /fill_background, fill_color = 'yellow', fill_level=0, $
> axis_style=0, linestyle='none')
> p2 = plot([0, 1], position = pos, current = win)
>
> -Chris

Victory! Many thanks, Chris.
Even so, fixing the background_color property might be easier.

All the best,

David
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Turning Axis Labelling Off
Next Topic: 3D matrix

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

Current Time: Wed Oct 08 17:11:19 PDT 2025

Total time taken to generate the page: 0.00714 seconds