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

Home » Public Forums » archive » Re: How to erase a (function graphics) 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: How to erase a (function graphics) plot. [message #79452] Mon, 05 March 2012 09:02 Go to next message
Mark Piper is currently offline  Mark Piper
Messages: 198
Registered: December 2009
Senior Member
On 3/5/2012 5:53 AM, alx wrote:
> On 5 mar, 06:27, wlandsman<wlands...@gmail.com> wrote:
>> I am building a widget application with a widget_window for displaying function graphics plots. By default, function graphics does not erase the old plot in the same window.
>>
>> p1 = plot(indgen(10))
>> p2 = plot( sin(indgen(10),/current)
>>
>> There is a delete method
>>
>> p1.delete
>>
>> but that doesn't delete the axes, which still get jumbled together. There is a close method but that destroys the window, and I'd like to keep reusing the widget_window.
>>
>> Right now I am erasing the plot by loading a white IMAGE() but I hope there is a better way.
>>
>> Thanks, --Wayne
>>
>>
>
> p1.delete looks like to be equivalent to p1.setdata(0), i.e. erasing
> only the data. If you want to erase the entire plot, you can erases
> the axes by doing:
> IDL> p1['AXIS0'].delete ;erase X axis
> IDL> p1['AXIS1'].delete ;erase Y axis
> alx.

In 8.2, there will be an ::Erase method for NG, analogous to ERASE for
DG. (In 8.0 & 8.1, I've "erased" plots as Alain has.)

mp
Re: How to erase a (function graphics) plot. [message #79455 is a reply to message #79452] Mon, 05 March 2012 04:53 Go to previous messageGo to next message
lecacheux.alain is currently offline  lecacheux.alain
Messages: 325
Registered: January 2008
Senior Member
On 5 mar, 06:27, wlandsman <wlands...@gmail.com> wrote:
> I am building a widget application with a widget_window for displaying function graphics plots.    By default, function graphics does not erase the old plot in the same window.
>
> p1 = plot(indgen(10))
> p2 = plot( sin(indgen(10),/current)
>
> There is a delete method
>
> p1.delete
>
> but that doesn't delete the axes, which still get jumbled together.     There is a close method but that destroys the window, and I'd like to keep reusing the widget_window.
>
> Right now I am erasing the plot by loading a white IMAGE() but I hope there is a better way.
>
>  Thanks, --Wayne
>
>

p1.delete looks like to be equivalent to p1.setdata(0), i.e. erasing
only the data. If you want to erase the entire plot, you can erases
the axes by doing:
IDL> p1['AXIS0'].delete ;erase X axis
IDL> p1['AXIS1'].delete ;erase Y axis
alx.
Re: How to erase a (function graphics) plot. [message #79551 is a reply to message #79452] Mon, 05 March 2012 09:07 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Mark Piper writes:

> In 8.2, there will be an ::Erase method for NG, analogous to ERASE for
> DG. (In 8.0 & 8.1, I've "erased" plots as Alain has.)

And welcome to the version-specific code writing world! ;-)

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: How to erase a (function graphics) plot. [message #88542 is a reply to message #79452] Sun, 11 May 2014 12:01 Go to previous messageGo to next message
Bob[4] is currently offline  Bob[4]
Messages: 24
Registered: April 2009
Junior Member
On Monday, March 5, 2012 10:02:57 AM UTC-7, Mark Piper wrote:
> On 3/5/2012 5:53 AM, alx wrote:
>
>> On 5 mar, 06:27, wlandsman<wlands...@gmail.com> wrote:
>
>>> I am building a widget application with a widget_window for displaying function graphics plots. By default, function graphics does not erase the old plot in the same window.
>
>>>
>
>>> p1 = plot(indgen(10))
>
>>> p2 = plot( sin(indgen(10),/current)
>
>>>
>
>>> There is a delete method
>
>>>
>
>>> p1.delete
>
>>>
>
>>> but that doesn't delete the axes, which still get jumbled together. There is a close method but that destroys the window, and I'd like to keep reusing the widget_window.
>
>>>
>
>>> Right now I am erasing the plot by loading a white IMAGE() but I hope there is a better way.
>
>>>
>
>>> Thanks, --Wayne
>
>>>
>
>>>
>
>>
>
>> p1.delete looks like to be equivalent to p1.setdata(0), i.e. erasing
>
>> only the data. If you want to erase the entire plot, you can erases
>
>> the axes by doing:
>
>> IDL> p1['AXIS0'].delete ;erase X axis
>
>> IDL> p1['AXIS1'].delete ;erase Y axis
>
>> alx.
>
>
>
> In 8.2, there will be an ::Erase method for NG, analogous to ERASE for
>
> DG. (In 8.0 & 8.1, I've "erased" plots as Alain has.)
>
>
>
> mp

Did this happen? I don't see it in 8.3.

An erase method would be very useful. I find that when I rerun a script that greats a (function graphics) plot it always creates a new window, which steals the focus (and pops up the new window in the wrong place). This drives me crazy. It would be much better if I could erase the old one and reuse the same window. Then my window layout would stay put and focus would stay in the editing window.

Am I missing something?

Bob
Re: How to erase a (function graphics) plot. [message #88543 is a reply to message #88542] Sun, 11 May 2014 18:19 Go to previous messageGo to next message
chris_torrence@NOSPAM is currently offline  chris_torrence@NOSPAM
Messages: 528
Registered: March 2007
Senior Member
>
> Did this happen? I don't see it in 8.3.
>
>
>
> An erase method would be very useful. I find that when I rerun a script that greats a (function graphics) plot it always creates a new window, which steals the focus (and pops up the new window in the wrong place). This drives me crazy. It would be much better if I could erase the old one and reuse the same window. Then my window layout would stay put and focus would stay in the editing window.
>
>
>
> Am I missing something?
>
>
>
> Bob

Yep...

http://www.exelisvis.com/docs/Erase_Method.html

Looks like it got missed in the docs for each graphics function, but it's there!
-Chris
Re: How to erase a (function graphics) plot. [message #88544 is a reply to message #88543] Mon, 12 May 2014 03:13 Go to previous messageGo to next message
andeh is currently offline  andeh
Messages: 23
Registered: April 2011
Junior Member
On Monday, 12 May 2014 02:19:10 UTC+1, Chris Torrence wrote:
>>
>
>> Did this happen? I don't see it in 8.3.
>
>>
>
>>
>
>>
>
>> An erase method would be very useful. I find that when I rerun a script that greats a (function graphics) plot it always creates a new window, which steals the focus (and pops up the new window in the wrong place). This drives me crazy. It would be much better if I could erase the old one and reuse the same window. Then my window layout would stay put and focus would stay in the editing window.
>
>>
>
>>
>
>>
>
>> Am I missing something?
>
>>
>
>>
>
>>
>
>> Bob
>
>
>
> Yep...
>
>
>
> http://www.exelisvis.com/docs/Erase_Method.html
>
>
>
> Looks like it got missed in the docs for each graphics function, but it's there!
>
> -Chris



I have a function that works most of the time to deal with this. You pass it to the CURRENT keyword in your fg plotting command.



;+
; NAME:
; current = FG_CURRENT( id )
;
;
; PURPOSE:
; Clear an object graphics window if it exists, so that re-running
; code doesn't created another set of plots in a new window. The
; function is designed to be passed directly to a plotting command
; via the CURRENT keyword.
;
; INPUT:
; id: Object reference for a function graphics plot.
;
;
; OUTPUT:
; Flag to be passed to plotting object. If the output is 1, then
; the object has been successfully cleared and selected so that
; the /CURRENT keyword should be correct.
;
;
; EXAMPLE USE:
;
; ;; Create the same plot twice.
; plot_object_0 = PLOT( [0,5] )
; plot_object_0 = PLOT( [5,0] )
;
; ;; Now use FG_CURRENT to clear instead of creating a new one.
; plot_object_1 = PLOT( [0,5], CURRENT=FG_CURRENT(plot_object_1) )
; plot_object_1 = PLOT( [5,0], CURRENT=FG_CURRENT(plot_object_1) )
;
;
;
; HISTORY:
; 17 FEB 2014 (AJAS) Created.
;
;-
FUNCTION FG_CURRENT, id

;; If there's an error, return current=0.
CATCH, Error_status
IF Error_status NE 0 THEN BEGIN
PRINT, 'FG_CURRENT: ', !ERROR_STATE.MSG
CATCH, /CANCEL
RETURN, 0b
ENDIF


;; Unless the current window is appropriately set,
;; we don't flag it.
current = 0b

;; Check that we are dealing with an object reference.
IF SIZE(/TYPE,id) EQ 11 THEN BEGIN

HELP, id, OUTPUT=help_id

;; If it looks like a plot, then erase the contents and select.
;; This is not an exhaustive check.
IF (STRSPLIT(/EXTRACT,help_id))[1] NE 'OBJREF' THEN BEGIN
wid = id.WINDOW
wid.ERASE
wid.SELECT
current = 1b
ENDIF

ENDIF


RETURN, current
END
Re: How to erase a (function graphics) plot. [message #88547 is a reply to message #88543] Mon, 12 May 2014 07:49 Go to previous messageGo to next message
Bob[4] is currently offline  Bob[4]
Messages: 24
Registered: April 2009
Junior Member
On Sunday, May 11, 2014 7:19:10 PM UTC-6, Chris Torrence wrote:
>>
>
>> Did this happen? I don't see it in 8.3.
>
>>
>
>>
>
>>
>
>> An erase method would be very useful. I find that when I rerun a script that greats a (function graphics) plot it always creates a new window, which steals the focus (and pops up the new window in the wrong place). This drives me crazy. It would be much better if I could erase the old one and reuse the same window. Then my window layout would stay put and focus would stay in the editing window.
>
>>
>
>>
>
>>
>
>> Am I missing something?
>
>>
>
>>
>
>>
>
>> Bob
>
>
>
> Yep...
>
>
>
> http://www.exelisvis.com/docs/Erase_Method.html
>
>
>
> Looks like it got missed in the docs for each graphics function, but it's there!
>
> -Chris

Thanks, Chris. This works, except that it doesn't erase the plot (it is still in the window). But plotting a new plot to current does erase it and plots the new one. Is this the intended behavior (I would have thought that erase would erase)?

I'm using IDL 8.3 on Mac OS X 10.9.2 (note that I use the X11 backend since I run it from X11 emacs).

Bob
Re: How to erase a (function graphics) plot. [message #88548 is a reply to message #88547] Mon, 12 May 2014 08:41 Go to previous message
chris_torrence@NOSPAM is currently offline  chris_torrence@NOSPAM
Messages: 528
Registered: March 2007
Senior Member
On Monday, May 12, 2014 8:49:02 AM UTC-6, bobnn...@gmail.com wrote:
> On Sunday, May 11, 2014 7:19:10 PM UTC-6, Chris Torrence wrote:
>
>>>
>
>>
>
>>> Did this happen? I don't see it in 8.3.
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> An erase method would be very useful. I find that when I rerun a script that greats a (function graphics) plot it always creates a new window, which steals the focus (and pops up the new window in the wrong place). This drives me crazy. It would be much better if I could erase the old one and reuse the same window. Then my window layout would stay put and focus would stay in the editing window.
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> Am I missing something?
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> Bob
>
>>
>
>>
>
>>
>
>> Yep...
>
>>
>
>>
>
>>
>
>> http://www.exelisvis.com/docs/Erase_Method.html
>
>>
>
>>
>
>>
>
>> Looks like it got missed in the docs for each graphics function, but it's there!
>
>>
>
>> -Chris
>
>
>
> Thanks, Chris. This works, except that it doesn't erase the plot (it is still in the window). But plotting a new plot to current does erase it and plots the new one. Is this the intended behavior (I would have thought that erase would erase)?
>
>
>
> I'm using IDL 8.3 on Mac OS X 10.9.2 (note that I use the X11 backend since I run it from X11 emacs).
>
>
>
> Bob

Yep, I noticed that also. I thought it was just a quirk on my Mac, but I can reproduce it on Windows as well... I'll go ahead and fix it for the next service pack.
Thanks!
-Chris
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Problem with IDLnetURL Callback Function
Next Topic: how to shade region of 2-D plot

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

Current Time: Wed Oct 08 13:39:11 PDT 2025

Total time taken to generate the page: 0.00504 seconds