tinyplot
tinyplot copied to clipboard
Default axis spacing parameters
I have spent 20 years trying to get par(lgp=) and other parameters to work for all base plot layouts (creating functions of mfrow etc) but have never found a solution as perfect as the defaults used by ggplot2. plot2 at present is wasting space for tick mark label placement and axis label placement. If you can solve that in plot2 I'm much more likely to use it. Thanks!
Thanks Frank. I'll just repeat parts of our BlueSky discussion for tracking here:
A design principle of this package is that the corners of the plot region should remain fixed, i.e. consistent with the mar margins. This reduces surprises when users switch from vanilla plot and also makes it easy to integrate facets in a principled way that limits spacing headaches done the line. ("Easier" being a slight misnomer as it actually requires quite a lot of work internally to make this work. But from the user perspective everything should work seamlessly.)
The upshot is that user-supplied margin settings—say, par(mar = c(2.5, 2.5, 2.5, 0)+.1, mgp = c(1.5, .5, 0), tck = -0.02)—that reduce whitespace and look good for a single plot, should also look good for faceted plots (and plots with an automatic legend, for that matter).
But you certainly raise a good point about improving the defaults, without requiring that users spend time fiddling with these (obscure) parameters. Simultaneously, I've been thinking about providing a themes function that would automatically do this with good defaults that integrate well with the rest of the package. I'll create a separate issue for this themes issue and link back to this one.
Thanks for the suggestion!
@harrelfe We just merged a PR which adds support for automatic theming via a tinytheme() function. Several of the canned themes (a) explitly attempt to reduce whitespace and (b) dynamically adjust plot margins to account for text elements (e.g. long horizontal y-axis labels.
See the helpfile and associated vignette:
- https://grantmcdermott.com/tinyplot/man/tinytheme.html
- https://grantmcdermott.com/tinyplot/vignettes/themes.html
Feel free to test drive yourself by grabbing the dev version of the package.