grantmcdermott / tinyplot

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

Wishlist: Global options #33

Closed grantmcdermott closed 6 months ago

grantmcdermott commented 1 year ago

Allow users to set things outside of par. ~Palette defaults would be an obvious candidate.~ (Not true: Should be via palette as per #44). Maybe default legend position. Other "theme" options like grid and frame.plot. Any others?

grantmcdermott commented 11 months ago

My current thinking: Add a par2() function for setting these additional global options, which would also "nest" conventional par arguments. (With the latter being passed through ...?) Supporting the nesting/passing of regular par arguments would allow users just to do everything through a single par2() call, instead of trying to remember which global options are supported by which function.

So, for example, par2(grid = TRUE, las = 1) would enact the first argument directly, but pass the second argument to par() internally.

J-Moravec commented 10 months ago

Is par2() planned to be used only for plot2 or perhaps for other derived custom functions, and thus would par2 members/fields be hard-coded?

For instance, I create a new plot (not necessarily) based on plot2 with a new argument specifying whatever. I would like to offload some parameters to par, but can't since those are hard-coded, this is impossible.

Also, something like plot2(..., style = par2(...)) to create a few styles that could be passed around would be cool, although I can't imagine many normal uses for this.

Love the PKG btw! Big fan of base R graphics and constantly annoyed by the difficulty of plotting legend.

grantmcdermott commented 7 months ago

Hi @J-Moravec sorry for being slow; this issue has been on the backburner. I’m going to turn my attention to it once #83 is merged (since that actually introduces par2 as a side effect, which could then be refined and expanded on).

Tbh I’m strongly inclined towards hard coding the par2 fields, since this would give us better control. No promises, but maybe if you can give some concrete examples I’ll reconsider?

Thanks for kind words about the package!

grantmcdermott commented 6 months ago

Closing, since the scaffolding for this now exists via par2.

At the moment, only a few global options are supported. I also haven't integrated the forward passing of arguments from par2 on to par. (I like the convenience of this latter idea.) But these features will be added in time.

Please feel free to raise suggestions for the specific par2 parameters/features as separate issues.