haotu : an open lab notebook


Angle axis x labels on R plot

Filed under: R, R graphics — S @ 04:13

1. First make a plot without the axis you want using xaxt="n":


2. Then add the axis without labels


side = 1 (this example is for adding labels to the x axis)

3. Finally add the text:

text(xx,par("usr")[3] - ofst, srt = g, adj = 1,labels=labs,xpd = TRUE)

par("usr")[3] gives you the y coordinate for your x axis
ofst is the offset at which you want to plot the labels away from the x axis (note the minus sign).
srt = g this gives the angle to plot the labels, I like (e.g., g = 45)
labs is a vector of your labels
xpd=TRUE plotting clipped to the figure region, also try xpd=NA


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: