Open trekonom opened 5 hours ago
Hello @trekonom
No problem, you can propose a PR, I'll happily review it. You can also ask if any help is needed. :)
[...] the "correct" naming for a unit(s)= argument [...]
yeahhh, to me it should be unit
as we express only one but I agree with you.
Hi David,
I'm aware that this FR is a duplicate of PR #319, which was reverted in #322 due to adding three copies of the plot when the
units=
argument was not set (as also reported in #323).I still think a
unit(s)=
argument would be a handy feature, and after looking at the implementation proposed in #319, I think the problem can be easily fixed.The problem with #319 is that the default was set to
units=c("in", "cm", "mm")
. As a result, three copies of the plot were created viaexternal_img
when theunits=
argument was not set. Side note: Nowadays, you already get an error inggsave
oragg_png
if you pass a vector with multiple units, which was not the case in older versions ofggplot2
, e.g. I checked withggplot2 3.2.0
.However, I think a working solution can be easily implemented by
unit = "in"
as defaultunit
is a vector of length 1Additionally, since the problem was caused by
external_img
creating multiple copies when a vector of length > 1 is passed to theunit=
argument, I'm wondering if a check should be added toexternal_img
as well?Finally, I'm wondering about the "correct" naming for a
unit(s)=
argument, i.e.ragg::agg_png
(orggsave
) usesunits=
while theofficer
package already usesunit=
. For consistency, sticking to theofficer
naming convention is probably the way to go. However, in this case it would be nice to add an informative (error) message if a user usesunits=
instead.What do you think of this suggestion? Feel free to assign it to me.