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

Home » Public Forums » archive » Controlling axis labels in IDL plots?
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
Controlling axis labels in IDL plots? [message #19698] Wed, 12 April 2000 00:00 Go to next message
Rachel Howe is currently offline  Rachel Howe
Messages: 6
Registered: May 1996
Junior Member
I wonder if anyone can help me with a graphics problem?

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?


Thanks in advance for any suggestions!


--
Rachel Howe
National Solar Observatory, Tucson AZ
rhowe@noao.edu
Re: Controlling axis labels in IDL plots? [message #19756 is a reply to message #19698] Fri, 14 April 2000 00:00 Go to previous messageGo to next message
Rachel Howe is currently offline  Rachel Howe
Messages: 6
Registered: May 1996
Junior Member
Mark Hadfield wrote:
>
> "Rachel Howe" <rhowe@noao.edu> wrote in message
> news:38F673F6.7A8BA656@noao.edu...
>>
>> And presumably one could go the other way using !D?
>
> !C stands for carriage return. Putting it at the beginning or end of the
> label shifts the label around by adding an empty line. !D is not the
> opposite of !C.
>


Of course. Sorry to be slow on the uptake!

Unfortunately, though I can make the TITLE and YTITLE move in and out
like anything by adding trailing or leading !c, the XTITLE will move
down but won't move up -- it just sits there while the extra lines go
trailing down the screen and off the edge of the window.
It's a pity there isn't a reverse-line-feed character .. . wait a
minute!
!a and !b shift text 'above or below the division line' -- ie half a
line up or down.
That works on the x axis. Adding in stuff like STRING(12B) doesn't seem
to help,
with the XTITLE either.

Failing that, there are the dubious delights of the ANNOTATE procedure
to experiment with.
(Has anyone else tried that and had their window jumping across the
screen?)

Thanks again for the suggestion!


--
Rachel Howe
National Solar Observatory, Tucson AZ
Re: Controlling axis labels in IDL plots? [message #19769 is a reply to message #19698] Fri, 14 April 2000 00:00 Go to previous messageGo to next message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
"Rachel Howe" <rhowe@noao.edu> wrote in message
news:38F673F6.7A8BA656@noao.edu...
>
> And presumably one could go the other way using !D?

!C stands for carriage return. Putting it at the beginning or end of the
label shifts the label around by adding an empty line. !D is not the
opposite of !C.

---
Mark Hadfield
m.hadfield@niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield/
National Institute for Water and Atmospheric Research
PO Box 14-901, Wellington, New Zealand
Re: Controlling axis labels in IDL plots? [message #19770 is a reply to message #19698] Thu, 13 April 2000 00:00 Go to previous messageGo to next message
Liam E. Gumley is currently offline  Liam E. Gumley
Messages: 378
Registered: January 2000
Senior Member
Rachel Howe <rhowe@noao.edu> wrote in message
news:38F673F6.7A8BA656@noao.edu...
> "Liam E.Gumley" wrote:
>>
>> Rachel Howe wrote:
>>>
> [Snip]
>>> Does anyone know how the distance of the axis label from the axis is
>>> determined in a single-panel 2d plot?
>>
> [Snip]
>>> 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_continents
>> 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
>> labels.
>>
>
>
> And presumably one could go the other way using !D?

!D actually shifts down to the first subscript level.

All you need to do is put the !C immediately before or after the title
string in question, to shift the title down or up relative to the default
position.

Cheers,
Liam.
Re: Controlling axis labels in IDL plots? [message #19771 is a reply to message #19698] Thu, 13 April 2000 00:00 Go to previous messageGo to next message
Rachel Howe is currently offline  Rachel Howe
Messages: 6
Registered: May 1996
Junior Member
Stein Vidar Hagfors Haugan wrote:
>
> In article <MPG.135ee234b9aa2a5989acb@news.frii.com>
> davidf@dfanning.com (David Fanning) writes:
>>
>> Rachel Howe (rhowe@noao.edu) writes:
> [..]
>>> 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?
>>
>> Ooohh, someone as anal as I am about the looks of things!
>> Thank goodness, I had just about abandoned all hope. :-)
>
> I guess you're entitled to be a little bit "anal" if your plots are
> appearing in the journal Science... See the first Report listed on
> this page: http://www.sciencemag.org/content/vol287/issue5462/


That did have something to do with it, yes. In the end, Science
relettered
most of the axes anyway, but we did TRY to get them right! Now I'm just
trying to produce a poster that's worth keeping after the meeting.

--
Rachel Howe
National Solar Observatory, Tucson
Re: Controlling axis labels in IDL plots? [message #19772 is a reply to message #19698] Thu, 13 April 2000 00:00 Go to previous messageGo to next message
Rachel Howe is currently offline  Rachel Howe
Messages: 6
Registered: May 1996
Junior Member
"Liam E.Gumley" wrote:
>
> Rachel Howe wrote:
>>
[Snip]
>> Does anyone know how the distance of the axis label from the axis is
>> determined in a single-panel 2d plot?
>
[Snip]
>> 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_continents
> 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
> labels.
>


And presumably one could go the other way using !D?


Thanks for the suggestion!

--
Rachel Howe
National Solar Observatory, Tucson
Re: Controlling axis labels in IDL plots? [message #19775 is a reply to message #19698] Thu, 13 April 2000 00:00 Go to previous messageGo to next message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Stein Vidar Hagfors Haugan (steinhh@ulrik.uio.no) writes:

> What's your excuse, David?

I don't have an excuse. I just always liked things to *look*
right. Probably stems from the first time I came home and told
my wife I had quit my job (without warning, as would become the
custom with me). "What do you plan to do now?", she asked me,
with just a little bit of threat in her voice. "Donno", I said,
"Maybe I'll draw scientific illustrations for a living."

And that's what I did. In those days we used expensive pens
and drew in India ink on vellum paper. If you made a mistake,
you had to white it out. If you made enough mistakes, you started
over. Since that cut into the profit margin pretty severely, I
learned to concentrate and not make any mistakes. My rule was:
three white-outs, and start over. I was very good at it, and I
damn sure learned how to align lettering on axes! :-)

The best part of the job was that I eventually learned how
to work at this while practicing my lines for the local
Community Theater productions. It made me productive both
day *and* night.

> Anyway, seems like Liam's suggestion is the best one can do without
> using XYOUTS. Note that prepending a "!C" on the Y axis title will
> push the text towards the axis, and likewise prepending one for the
> X axis title will push it down.

Pretty neat trick, huh? I've already updated my book, since
this is the only thing I have ever found that successfully
gets that X axis label in the right place.

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: Controlling axis labels in IDL plots? [message #88487 is a reply to message #19698] Thu, 01 May 2014 14:57 Go to previous messageGo to next message
laura.hike is currently offline  laura.hike
Messages: 87
Registered: September 2013
Member
On Friday, April 14, 2000 12:00:00 AM UTC-7, Rachel Howe wrote:
> Mark Hadfield wrote:
>>
>> "Rachel Howe" <rhowe@noao.edu> wrote in message
>> news:38F673F6.7A8BA656@noao.edu...
>>>
>>> And presumably one could go the other way using !D?
>>
>> !C stands for carriage return. Putting it at the beginning or end of the
>> label shifts the label around by adding an empty line. !D is not the
>> opposite of !C.
>>
>
>
> Of course. Sorry to be slow on the uptake!
>
> Unfortunately, though I can make the TITLE and YTITLE move in and out
> like anything by adding trailing or leading !c, the XTITLE will move
> down but won't move up -- it just sits there while the extra lines go
> trailing down the screen and off the edge of the window.
> It's a pity there isn't a reverse-line-feed character .. . wait a
> minute!
> !a and !b shift text 'above or below the division line' -- ie half a
> line up or down.
> That works on the x axis. Adding in stuff like STRING(12B) doesn't seem
> to help,
> with the XTITLE either.
>
> Failing that, there are the dubious delights of the ANNOTATE procedure
> to experiment with.
> (Has anyone else tried that and had their window jumping across the
> screen?)
>
> Thanks again for the suggestion!
>
>
> --
> Rachel Howe
> National Solar Observatory, Tucson AZ


Wow, 14 years later and this is still a problem!! Is there any way to move the y-axis title closer to the axis? I tried all of the tricks listed above and none of them worked. !C at the beginning keeps the edge at the same place but just stretches the letters to the right, !C at the end pushes the whole title off the edge of the plot area, and a leading !b does move the text inward UNTIL it gets to a superscript, which actually moves up a line and off the edge of the page. Can't we just set the damned position of the title?? There are so many other aspects of a plot that can be controlled.

I managed to get the title onto the page by resetting the margins, but I think the plot looks stupid because the title is so far away from the axis.
Re: Controlling axis labels in IDL plots? [message #88489 is a reply to message #88487] Thu, 01 May 2014 16:59 Go to previous messageGo to next message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
I tried changing the line spacing. It has an effect on the x-axis, but not on the y-axis. XYOuts (or cgText) is still probably your best bet, if you are sticking with direct graphics.

Compare this

plot, randomu(0,100), XTITLE='X Title', YTITLE='Y Title'

To this

window, /free
charsize = !d.x_ch_size
spacing = !d.y_ch_size
device, SET_CHARACTER_SIZE=[!d.x_ch_size, 0.8*!d.y_ch_size]
plot, randomu(0,100), XTITLE='X Title', YTITLE='Y Title'
device, SET_CHARACTER_SIZE=[charsize, spacing]
Re: Controlling axis labels in IDL plots? [message #88493 is a reply to message #88489] Thu, 01 May 2014 18:10 Go to previous message
laura.hike is currently offline  laura.hike
Messages: 87
Registered: September 2013
Member
On Thursday, May 1, 2014 4:59:43 PM UTC-7, Matthew Argall wrote:
> I tried changing the line spacing. It has an effect on the x-axis, but not on the y-axis. XYOuts (or cgText) is still probably your best bet, if you are sticking with direct graphics.
>
>
>
> Compare this
>
>
>
> plot, randomu(0,100), XTITLE='X Title', YTITLE='Y Title'
>
>
>
> To this
>
>
>
> window, /free
>
> charsize = !d.x_ch_size
>
> spacing = !d.y_ch_size
>
> device, SET_CHARACTER_SIZE=[!d.x_ch_size, 0.8*!d.y_ch_size]
>
> plot, randomu(0,100), XTITLE='X Title', YTITLE='Y Title'
>
> device, SET_CHARACTER_SIZE=[charsize, spacing]


Unfortunately, I don't know any other way to make a box plot. I've always used the traditional graphics procedure in the past....
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Font size appearance in function graphics PNG and EPS output
Next Topic: Full page plot in postcript

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

Current Time: Wed Oct 08 15:27:43 PDT 2025

Total time taken to generate the page: 0.00728 seconds