I have a plot that has $-amounts and dates on y and x axis respectively. Currently the dollar amounts range from $0-15 million. Something like this:
x <- rnorm(20)^2 * 1000000
plot(x)
R does stuff like '1.0e+07' instead of '10,000,000' and also orients the text vertically instead of horizontally.
My questions are:
1) how would I get the scale text to be horizontally oriented?
2) how would I get R to use 10MM instead of '10,000,000' or '1.0e+07'?
1) See the
scipenoption in?optionswhich is a penalty against the use of scientific notation. For better control, you need to plot the axis by hand with labels you want.2) See
lasin?parwhich controls to orientation crudely of axis labels.For 1):
which gives
To plot your own axis try
Which gives
Where we use
pretty()to select pretty locations for the ticks just as R would and then add a custom axis. Notice how we suppress axis drawing in theplot()call and then add back the axes and the plot frame with calls toaxis()andbox().For 2) combining with 1)
Which gives
Notice how we use
lasin theplot()call, and we need to create some extra margin space to accommodate the tick labels. We also need to plot the label by hand otherwise R will stick it in amongst the tick labels.For the custom axis labels, add the
las = 1to theaxis()call:Which produces