When I want to add ab/h/v-lines in histograms I can do something like:
tinyplot(~ body_mass, data = penguins, type = "histogram")
tinyplot_add(type = type_vline(4500), lwd = 2, col = 2)
However, when I use the two-sided formula body_mass ~ 1 instead of the one-sided ~ body_mass, then I get the automatic dispatch to the histogram but the ab/h/v-line is ignored:
tinyplot(body_mass ~ 1, data = penguins)
tinyplot_add(type = type_vline(4500), lwd = 2, col = 2) ## ignored
The reason seems to be that tinyplot.default() infers the display to be an empty_plot in this code:
https://github.com/grantmcdermott/tinyplot/blob/main/R/tinyplot.R#L1501-L1505
Because "histogram" is explicitly exempt in the empty_plot rule, the histogram works. But the ab/h/v-lines are not drawn at all.
I guess we could (or should?) explicitly exempt ab/h/v-line as well? But maybe the empty_plot should also correctly catch y ~ 1 displays in general?
When I want to add ab/h/v-lines in histograms I can do something like:
However, when I use the two-sided formula
body_mass ~ 1instead of the one-sided~ body_mass, then I get the automatic dispatch to the histogram but the ab/h/v-line is ignored:The reason seems to be that
tinyplot.default()infers the display to be anempty_plotin this code:https://github.com/grantmcdermott/tinyplot/blob/main/R/tinyplot.R#L1501-L1505
Because
"histogram"is explicitly exempt in theempty_plotrule, the histogram works. But the ab/h/v-lines are not drawn at all.I guess we could (or should?) explicitly exempt ab/h/v-line as well? But maybe the
empty_plotshould also correctly catchy ~ 1displays in general?