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

Home » Public Forums » archive » Rotating tick labels in DG
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Rotating tick labels [message #22546 is a reply to message #22162] Wed, 15 November 2000 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
TomC (tom_syn58@hotmail.com) writes:

> I am using IDL 5.4 to create PostScript files of plain old X-Y plots. Some
> of the plots have usernames as the x-axis tick labels. When there are lots
> of users, or long names and lots of users, the labels overwrite each other,
> creating an un-readable mess. Is there an easy way to have the tick labels
> created at an angle? Thanks in advance.

I have a short section in my book about how this can be done.
I was going to take it out of the 2nd Edition because I was
trying to save pages and I thought "who would ever need to
know how to do this?". But at the last minute I left it in.
You never know. :-)

Anyway, if you mean by "easy" some kind of keyword switch,
then the answer is "no". But is is not too hard either.

Suppose you are going to have 5 tick intervals, labeled
with 6 tick labels on the X axis:

numticks = 5
labels = ['One', 'Two', 'Three', 'Four', 'Five', 'Six']

Draw the plot, leaving some room for the rotated labels:

Plot, findgen(11), XTickFormat='(A1)', XStyle=1, $
XTicks=numticks, Position=[0.1, 0.2, 0.85, 0.95]

Calculate positions for the labels:

ypos = Replicate(!Y.Window[0] - 0.04, numticks+1)
xpos = !X.Window[0] + (!X.Window[1] - !X.Window[0]) * $
Findgen(numticks + 1) / numticks

Position the labels:

FOR j=0, numticks DO XYOutS, xpos[j], ypos[j], $
labels[j], Alignment=0.0, Orientation=-45, /Normal

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
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: IDL Programming Techniques, 1st edition on ebay
Next Topic: Julian Day Numbers

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

Current Time: Sat Oct 11 02:10:44 PDT 2025

Total time taken to generate the page: 0.88004 seconds