[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Controlling axis labels in IDL plots?

Rachel Howe wrote:
> I'm getting very finicky about my IDL plots. (I use direct graphics
> only, no objects --
> conceptually I'm still in the v3.6 era).
> I've learned to use the !p, !x and !y system variables, their associated
> keywords,
> and the axis command, to override most of the defaults, but one thing
> eludes me.
> Does anyone know how the distance of the axis label from the axis is
> determined in a single-panel 2d plot?
> There doesn't seem to be any way to control it directly, but it must be
> some arcane function of the plot area, position/margin settings, and
> character size. If anyone knows an algorithm, I'd be delighted to hear
> it.
> Or would it be easier to give up and just use
> XYOUTS to put the annotations where I want them?

Here's a quick and dirty method which can be used to push the X and Y
axis labels further away from the axes using the !C (carriage return)
font positioning code:

;- Set a reasonable character size and create data
device, set_character_size=[10, 12]
x = findgen(200) * 0.1
y = sin(x)

;- Default axis label positions
plot, x, y, xtitle='X AXIS', ytitle='Y AXIS'

;- Move X axis label down one character
IDL> plot, x, y, xtitle='!CX AXIS', ytitle='Y AXIS'

;- Move Y axis lable left one character
IDL> plot, x, y, xtitle='X AXIS', ytitle='Y AXIS!C'

I find this particularly useful when adding titles to maps which have a
box grid:

window, /free
map_set, -30, 130, scale=40e6, $
  xmargin=[2, 2], ymargin=[2, 4], title='MAP TITLE!C'
map_grid, /box, charsize=0.75

Unless you add the trailing !C to the title, it is displayed at the same
height as the top row of longitude labels. If this method doesn't suit
your needs, I think you will have to resort to manually positioned