grantmcdermott / tinyplot

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

Default axis spacing parameters #112

Open harrelfe opened 5 months ago

harrelfe commented 5 months ago

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!

grantmcdermott commented 5 months ago

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!