When using barplot with add y2 axis for lines or points by par(new=TRUE) as show in the example code usually get shifted.
The updateusr method from Greg Snow's TeachingDemos package is a great solution for this problem. The idea behind updateusr is define new plot region according to the ratio of one unit in each axis.
The code:
Example code:(add space 8/20)
Result:
2015/08/19
2009/02/18
Axis scaling algorithm
A good look axes scale usually increase by 10^(x) or 0.5*10^(x) according to the data's range. Dorothy E. Pugh provide an algorithm (and SAS Macro) for generated suitable axis scale, I modified the SAS code into R code
reference:Dorothy E. Pugh(SUGI25), "A Robust Generalized Axis-scaling Macro"
reference:Dorothy E. Pugh(SUGI25), "A Robust Generalized Axis-scaling Macro"
訂閱:
文章 (Atom)