[R] Missing axis labels

David L Carlson dcarlson at tamu.edu
Fri May 1 17:26:55 CEST 2015


I don't think you can tell in advance since the details of the plot are computed when you open the plot window and they change when you plot into the window. In principal you could estimate the size requirements for the axis labels if you know the plot window size and the character size. What gets plotted is also device dependent. For example if you open a window using x11(3, 3) (I'm on windows so I haven't tried this on OS X) and produce the plot, the last x-axis is missing just as in the pdf file. But if you drag the window to make it larger, the label will appear when the device driver redraws the plot.

There is also a third option in addition to your two to getting all of the labels:

plot(0:100, 0:100, xaxp=c(0, 100, 4))

will plot at 0, 25, 50, 75, 100 which leaves room for the last label.

-------------------------------------
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352



-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Fisher Dennis
Sent: Friday, May 1, 2015 9:11 AM
To: r-help at stat.math.ethz.ch
Subject: [R] Missing axis labels

R 3.2.0
OS X
This is a general question, not specific to OS X.  

Colleagues

Often, one or more values on an axis will be omitted, presumably in order to prevent overlap.  However, there are situations where I would like to override that omission.  Sample code:
	pdf("labels.pdf", width=3, height=3)
	plot(0:100, 0:100)
	graphics.off()
Here, 100 is omitted from the x-axis and 20, 60, and 100 from the y-axis. 

Is there is automated way to detect which values will be omitted (i.e., without seeing the graphic)?  

If so, I see two options:
	1.  change the font size
	2.  force the entry, e.g., axis(1, 100, at=100)

Dennis


Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.com

______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list