Fanning Software Consulting

Resized Graphics Windows Rearrange Content

QUESTION: Well, I will say this, the resizeable graphics windows in IDL 8.1 actually resize themselves. But would it be asking too much for them to avoid rearranging the contents of the window, too? I position graphics carefully in the window using the Position keyword, but when the window is resized, God only knows where things are going to end up!

ANSWER: Yes, I am afraid you are right, the resizeable graphics windows in IDL 8.1 just seem to be broken. I have had numerous reports of graphics elements not just shifting position as the window is resized, but actually changing the graphics as well. For example, images on map projections will start out filling the the entire map projection, but then will cover only a fraction of the map projection when the window is resized.

Here is a simple example of the general problem. We first position a legend on a plot. The Position keyword is used to position the upper left corner of the legend in data coordinate space.

   p1 = Plot(Findgen(20)+1, Name='Line 1')
   p2 = Plot(Findgen(20)*2+1, Name='Line 2', LineStyle=2, /Overplot)
   leg = Legend(Position=[2.5,30], /Data)

The legend first appears in the correct location on the plot, as shown in the figure below.

The legend appears in the correct location.
The legend starts off in the correct locaton.
 

Now we simply resize the graphics window. The legend changes location, as shown in the figure below.

The legend moves to a different location.
The legend moves to a different location when the graphics window is resized.
 

Sometimes the graphic element can be located outside the graphics window!

Here is an example in which a positioned color bar is positioned in such a way that the color bar is too large for the resized graphics window. The code I am running can be found in this article. Here is the original graphics window as it first appears.

The colorbar is displayed in the correct location.
The color bar appears correctly above the map projection.
 

And here is the same window after it has been resized. The color bar is now positioned outside the graphics window!

The colorbar is now positioned outside the window.
The color bar is now positioned outside the graphics window!
 

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

Written: 21 September 2011