Fanning Software Consulting

Window Refreshing Affects Relative Position

Facebook Twitter RSS Google+

INFORMATION: In the spirit of sharing knowledge about function graphics, Gordon Farquharson presents the following knowledge gained after what he called some “quality hair pulling time.”

A great trick when plotting large amounts of data with function graphics is to disable drawing in the window. For example, like this.

   w1 = Window(DIMENSIONS=[800, 400])
   w1.Refresh, /DISABLE
   data = Dist(1000,1000)
   im1 = Image(data, CURRENT=w1, IMAGE_DIMENSIONS=[60,30], IMAGE_LOCATION=[25,25], AXIS_STYLE=2)
   w1.Refresh

Another nice feature of function graphics is relative coordinate positioning. For example, we can add a color bar to the right of the image like this.

   cb1 = Colorbar(TARGET=im1, ORIENTATION=1, TEXTPOS=1, POSITION=[1.025,0.,1.050, 1.], /RELATIVE)

You see the result in the figure below.

Relative positioning and window refreshing work great.
Relative positioning and window refreshing work great together.
 

However, disabling window refresh and relative coordinate positioning do not play nicely together. For example, try this.

   w1 = Window(DIMENSIONS=[800, 400])
   w1.Refresh, /DISABLE
   data = Dist(1000,1000)
   im1 = Image(data, CURRENT=w1, IMAGE_DIMENSIONS=[60,30], IMAGE_LOCATION=[25,25], AXIS_STYLE=2)
   cb1 = Colorbar(TARGET=im1, ORIENTATION=1, TEXTPOS=1, POSITION=[1.025,0.,1.050, 1.], /RELATIVE)
   w1.Refresh

The result is not what you would expect (and rather frustrating if you try it first). You see the result in the figure below.

Relative positioning and window refreshing don't work so great if the order of refreshing is changed.
Relative positioning and window refreshing don't work so great if the order of refreshing is changed.
 

Version of IDL used to prepare this article: IDL 8.2.3.

Written: 18 May 2014