[R] controlling usage of digits & scientific notation in R plots; postscript margins
pauljohn at ku.edu
Wed Sep 21 23:42:52 CEST 2005
Dear R users:
I assigned students to make some graphs and I'm having trouble answering
some questions that they have. We are all working on R 2.1 on Fedora
Core Linux 4 systems.
1. In the plot, the axis is not labeled by "numbers", but rather
scientific notation like "-2e+08" or such. We realize that means
-200,000,000. We want to beautify the plot. We would rather just print
out the whole, big number. But if we can't have that, we would like
something more beautiful and mathematical, such as
Once the numbers are big, R automagically switches to scientific
notation, and turning the values horizontal does not help on the y axis.
x <- rnorm(100,mean=100000,sd=100000000)
y <- rnorm(100,mean=10000000000,sd=100000000000)
axis(2,las=2) #turns y axis numbers perpendicular to y axis
axis(1) # x axis
I realize a person could just divide all numbers by 1 million and then
have a graph with -200 and an annotation (in millions).
On the x axis, we'd even settle to just label the two outermost points
with full numerical values, and then have only ticks between. I was
looking for some way to use axis() to draw an unlabeled axis and then
put in text labels after that. However, I can't understand how to get
the values of the tick marks placed by axis from the figure in order to
place text by some tick marks.
2. Some students make postscript figures that fit "just right" into
LaTeX documents, while some make figures that have huge,
inches-and-inches of margins around the outside. I'm not watching how
they make these figures all the time, but I think I'm figuring out the
cause of big margins.
Is this right: the margins issue relates to the use of the onefile=F
option in a dev.copy command? I think the figures turn out properly
If you mistakenly omit the onefile=F option, the margins stretch out
from the center where the figure is placed to the edges of an entire
sheet of paper. In other words, the default settings for margins in
inches that I see in output from
 1.0066821 0.8092935 0.8092935 0.4145162
have no effect if a person forgets the onefile=F option. We fiddled a
while, trying to force margins down, par(mai=c(0,0,0,0)), but no matter
what we did, the figures still had the massive margins.
We don't have these margin problems with other devices. Margins in jpeg
or png pictures are sized appropriately.
Paul E. Johnson email: pauljohn at ku.edu
Dept. of Political Science http://lark.cc.ku.edu/~pauljohn
1541 Lilac Lane, Rm 504
University of Kansas Office: (785) 864-9086
Lawrence, Kansas 66044-3177 FAX: (785) 864-5700
More information about the R-help