grantmcdermott · GitHub

@zeileis @vincentarelbundock This PR should now be ready for review. I think that I've managed to plug the main issues that came up in testing and everything seems to work as expected. Dual legend support required some internal changes that made the code a bit uglier, but I don't think that can be avoided.

Some quick examples:

pkgload::load_all("~/Documents/Projects/tinyplot/")
tinytheme("clean")
plt(
  Life.Exp ~ Income | Illiteracy < 1, data = data.frame(state.x77),
  cex = state.x77[, 'Area']
)
bubble1

In the absence of NSE support for cex (see PS below), we can use with() instead of tinyplot.formula... Slightly fancier version of the previous plot.

with(
    data.frame(state.x77),
    plt(
        x = Income, y = Life.Exp,
        by = Illiteracy < 1,
        pch = 19, alpha = 0.5,
        cex = Area, clim = c(1, 5),
        main = "Life expectancy among US states (1977)"
    )
)
bubble2

Dual continuous × continuous legends work too.

with(
    data.frame(state.x77),
    plt(
        x = Income, y = Life.Exp,
        by = Population,
        pch = 21, bg = 0.4,
        cex = Area, clim = c(1, 6),
        main = "Life expectancy among US states (1977)"
    )
)
bubble3

P.S. I couldn't quite get NSE processing for cex to work properly with tinyplot.formua(..., cex = <variable>). Specifically, while I was able to pass/process the cex variable as part of the model frame, and ultimately generate the bubble legend, I wasn't able to get the legend title right. (Instead of the actual variable name, it would always say "cex".) @zeileis perhaps we can troubleshoot this issue as part of the current PR or a separate one (as you prefer).

Read the original on github.com ↗