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

Home » Public Forums » archive » Tribulations with IDL 8.1 graphics legend function and log axes
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
Tribulations with IDL 8.1 graphics legend function and log axes [message #75890] Mon, 18 April 2011 13:22
Sean[1] is currently offline  Sean[1]
Messages: 11
Registered: July 2005
Junior Member
Hi all,

I was having a problem getting legend() to work properly with plots
containing log axes. I figured out a simple workaround to get them to
work, but this is a real big annoyance/bug that ITT needs to fix!

Here's a simple example to illustrate:

;This call to legend works fine -- it places the legend in data space
at x=5, y=5
a = plot( findgen(20)+1, name='Test 1')
b = plot( findgen(20)*2+1, name='Test 2',/overplot)
c = legend( position=[5,5], data=1)

;This call places the legend somewhere off the graph
a = plot( findgen(20)+1, name='Test 1',ylog=1)
b = plot( findgen(20)*2+1, name='Test 2',/overplot)
c = legend( position=[5,5], data=1)

To confirm that the legend is off the screen, print the variable c
IDL> print, c
LEGEND <477233>
COLOR = 0 0 0
FONT_NAME = 'Helvetica'
FONT_SIZE = 12.000000
FONT_STYLE = 0
HIDE = 0
HORIZONTAL_ALIGNMENT = 0.0000000
HORIZONTAL_SPACING = 0.020000000
LINESTYLE = 0
NAME = 'Legend'
ORIENTATION = 0
POSITION = 0.32750000 2.0300000
SAMPLE_WIDTH = 0.15000000
SHADOW = 1
TEXT_COLOR = 0 0 0
THICK = 1.00000
TRANSPARENCY = 0
VERTICAL_ALIGNMENT = 1.0000000
VERTICAL_SPACING = 0.020000000

The position of the plot is listed in normalized coordinates, and in
this case the 0.3275 number is correct and corresponds to a (x) data
coordinate of 5. However, the y coordinate is way off the window.

It turns out that when you have log axes ans specify position in the
call to legend, IDL interprets the number you put in in log space, so
rather than
c = legend( position=[5,5], data=1)
you should put in
c = legend( position=[5,alog10(5)], data=1)

Uhm... Does this not seem like an obvious bug? or am i just thick?

Sean Davis
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Can't set brakpoints using emacs idlwave_shell
Next Topic: time series plot, second x-axis

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

Current Time: Wed Oct 08 19:44:12 PDT 2025

Total time taken to generate the page: 0.00531 seconds