grantmcdermott / tinyplot

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

Add argument `log` #15

Closed etiennebacher closed 1 year ago

etiennebacher commented 1 year ago

As I said in #4, I'm not an expert with base R plots but it seems to work fine:

library(plot2)

# from ?plot.default
lx <- seq(1, 5, length.out = 41)
yl <- expression(e^{-frac(1,2) * {log[10](x)}^2})
y <- exp(-.5*lx^2)

plot(10^lx, y, log = "xy", type = "l", col = "purple",
     main = "Log-Log plot", ylab = yl, xlab = "x")


plot2(10^lx, y, log = "xy", type = "l", col = "purple",
     main = "Log-Log plot", ylab = yl, xlab = "x")

grantmcdermott commented 1 year ago

Excellent! Let's see how the tests shake out. (There's a bit of a tricky situation in that we need the plots to have been generated from a Linux instance, which you hopefully are.)

UPDATE: Looks like you need to update the docs (devtools::document() or similar).

Could I also request an extra test using a logged axis (axes) and the by (or |) argument? Just want to make sure there isn't some unexpected interaction with grouped plots.

etiennebacher commented 1 year ago

Looks like you need to update the docs (devtools::document() or similar).

Ah right, thanks

from a Linux instance, which you hopefully are.

Yes I have Ubuntu 22.10

Could I also request an extra test using a logged axis (axes) and the by (or |) argument?

Hum turns out it's trickier than I thought. I can't even put two plot2() side-by-side. I'll have a look tomorrow but feel free to jump into this one if you have time ;)

grantmcdermott commented 1 year ago

Hum turns out it's trickier than I thought. I can't even put two plot2() side-by-side.

That's an internal restriction. We can't use mfrow on grouped plot2's, because we need to alter the par's internally for legend adjustment etc. I'm hoping to fix/accommodate this in a future iteration. But for now, just feel free to test a single grouped plot a la plot2(log(Temp) ~ Day | Month, airquality).

grantmcdermott commented 1 year ago

Closes #16.

grantmcdermott commented 1 year ago

Will add another test separately. Thanks @etiennebacher!