hafen / trelliscopejs

TrelliscopeJS R Package
https://hafen.github.io/trelliscopejs
Other
263 stars 36 forks source link

Legend #36

Closed schloerke closed 7 years ago

schloerke commented 7 years ago

Solves: #29

Also pulls in PR #27 (which in turn does #26 and #20). Merging this PR would auto merge the other three PRs

schloerke commented 7 years ago
library(ggplot2)
mpg2 <- mpg
mpg2$drv <- as.factor(mpg2$drv)
mpg2$cyl <- as.factor(mpg2$cyl)

load_all(); qplot(displ, hwy, data = mpg2) + facet_trelliscope(~ year, ncol = 2, nrow = 1, scales = "sliced", path = "_ignore/simple_split")
load_all(); qplot(displ, hwy, data = mpg2, color = year) + facet_trelliscope(~ year, ncol = 2, nrow = 1, scales = "sliced", path = "_ignore/simple_split_color")
load_all(); qplot(displ, hwy, data = mpg2) + facet_trelliscope(~ year, ncol = 2, nrow = 1, scales = "sliced", split_layout = FALSE, path = "_ignore/simple_whole")
load_all(); qplot(displ, hwy, data = mpg2, color = year) + facet_trelliscope(~ year, ncol = 2, nrow = 1, scales = "sliced", split_layout = FALSE, path = "_ignore/simple_whole_color")
hafen commented 7 years ago

Thanks for all this! The scales aspect works great!

I merged this PR and made some edits and put it here: https://github.com/hafen/trelliscopejs/tree/schloerke-legend.

What I did:

Something to think about: When either axis is set to "free" or "sliced", we know the axis will vary per panel so we might as well leave the axes in the plot. Only in the case of an axis being "same" we could just store a single instance of the axis (instead of writing out an axis per panel). That would result in a lot fewer files and calls to make_png() and would simplify things on the viewer's end. We can discuss this more later.