2015/08/19

updateusr method for better barplot with lines/points

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:

CC Copyright

創用 CC 授權條款
本著作由Chunhung Chou製作,以創用CC 姓名標示-相同方式分享 3.0 Unported 授權條款釋出。