There is a discussion on the evaluate repo about hook handling in tinytheme(). Moving here to discuss the tinyplot-specific issues, instead of polluting everyone's mentions in the other repo. Tag @grantmcdermott
The tinytheme() design uses a before.plot.new hook to set persistent theme parameters. In principle, hooks can be specified as a list, and many can be specified and applied sequentially before drawing the plot. However,
- Most of the time
tinytheme() wants to reset parameters (i.e., delete existing hooks) to default values before applying its own.
- AFAICT, there is not a great mechanism in R to "tag" or "name" elements of the hook list, that would enable us to identify the
tinyplot-specific hooks.
Because of 2, we cannot filter the hook list, that is, we cannot only remove those that we know for sure we have set. Instead, we call:
setHook("before.new.plot", NULL, "replace")
This removes ALL hooks, including some that might have been set by other packages, such as evaluate.
I don't remember all the details, but I do remember trying many alternatives to this when implementing. All had really fiddly edge cases, with theme elements not being reset and such. Frankly, I think this is above my pay grade, as I'm not that great with R graphics.
There is a discussion on the
evaluaterepo about hook handling intinytheme(). Moving here to discuss thetinyplot-specific issues, instead of polluting everyone's mentions in the other repo. Tag @grantmcdermottThe
tinytheme()design uses abefore.plot.newhook to set persistent theme parameters. In principle, hooks can be specified as a list, and many can be specified and applied sequentially before drawing the plot. However,tinytheme()wants to reset parameters (i.e., delete existing hooks) to default values before applying its own.tinyplot-specific hooks.Because of 2, we cannot filter the hook list, that is, we cannot only remove those that we know for sure we have set. Instead, we call:
This removes ALL hooks, including some that might have been set by other packages, such as
evaluate.I don't remember all the details, but I do remember trying many alternatives to this when implementing. All had really fiddly edge cases, with theme elements not being reset and such. Frankly, I think this is above my pay grade, as I'm not that great with R graphics.