grantmcdermott / tinyplot

Lightweight extension of the base R graphics system
https://grantmcdermott.com/tinyplot
Apache License 2.0
208 stars 7 forks source link

Handling of grid = TRUE #78

Closed zeileis closed 10 months ago

zeileis commented 10 months ago

If grid = TRUE is specified, then the new abline(... = pretty(extendrange(...)), ...) is used now instead of grid() - and not just for date/time classes (see https://github.com/grantmcdermott/plot2/issues/77).

Reason: Unlike grid(), the function pretty() is generic. Thus, it can adapt better to axes for variables of other classes.

Only exception: For axes in logs, we still resort to using grid() which is likely handled better there.

Potential downside: In all cases I tried, the pretty(extendrange(...)) approach yielded the same grid positions as grid(). But there may be situations when differences occur. However, in the examples I tried, I wasn't able to produce such a situation.