I have a simple plot:
#!/usr/bin/Rscript
png('plot.png')
y <- c(102, 258, 2314)
x <- c(482563, 922167, 4462665)
plot(x,y)
dev.off()
R uses 500, 1000, 1500, etc for the y axis. Is there a way I can use scientific notation for the y
axis and put * 10^3
on the top of the axis like the figure below?
A similar technique is to use
eaxis
(extended / engineering axis) from the sfsmisc package.It works like this:
How you get the labels onto your axis depends upon the used plotting system.(base, ggplot2 or lattice) You can use functions from
scales
package to format your axis numbers:Here an example using
ggplot2
:EDIT The OP has a specific need. Here some ideas I used here in order to accomplish this :
axis
function.mtext
to put text in the outer plot regionThis is sort of a hacky way, but there's nothing wrong with it: