diff --git a/R/by_aesthetics.R b/R/by_aesthetics.R
index af2f115f..09e9b8fe 100755
--- a/R/by_aesthetics.R
+++ b/R/by_aesthetics.R
@@ -20,7 +20,7 @@ by_col = function(ngrps = 1L, col = NULL, palette = NULL) {
if (is.null(palette)) {
if (ngrps<=8) {
- palette = "Okabe-Ito" #"R4"
+ palette = "R4"
palette_fun = palette.colors
} else {
palette = "Viridis"
diff --git a/R/plot2.R b/R/plot2.R
index 1931e6bb..10eeedcc 100644
--- a/R/plot2.R
+++ b/R/plot2.R
@@ -51,10 +51,13 @@
#' and tries to make the process more seemless with better default behaviour.
#' @param asp the y/xy/x aspect ratio, see `plot.window`.
#' @param palette one of the following options:
-#' - NULL (default), in which case R's default colour palette will be used.
-#' - A string corresponding to one of the palettes in either `palette.pals()`
-#' `hcl.pals()`. These can be case-insensitive (e.g., "viridis" and "Viridis"
-#' are both valid).
+#' - NULL (default), in which case the palette will be determined by the
+#' number of groups. If this number is equal to 8 or less, then R's default
+#' ("R4") colour palette will be used. For larger group numbers, the
+#' "Viridis" palette will be used instead.
+#' - A convenience string corresponding to one of the many palettes listed by
+#' either `palette.pals()` or `hcl.pals()`. Note that the string can be
+#' case-insensitive (e.g., "Okabe-Ito" and "okabe-ito" are both valid).
#' - A palette-generating function. This can be "bare" (e.g.,
#' `palette.colors`) or "closed" with a set of named arguments (e.g.,
#' `palette.colors(palette = "Okabe-Ito", alpha = 0.5)`). Note that any
@@ -161,9 +164,11 @@
#' legend.position = "topright", legend.args = list(bty="o", title = "Month")
#' )
#'
-#' # The default group colours are inherited from either the "Okabe-Ito" or
-#' # "Viridis" palettes, depending on the number of groups. However, all
-#' # palettes listed by `palette.pals()` and `hcl.pals()` are supported.
+#' # The default group colours are inherited from either the "R4" or "Viridis"
+#' # palettes, depending on the number of groups. However, all palettes listed
+#' # by `palette.pals()` and `hcl.pals()` are supported as convenience strings,
+#' # or users can supply a valid palette-generating function for finer control
+#' # over transparency etc.
#'
#' plot2(
#' Temp ~ Day | Month,
diff --git a/README.Rmd b/README.Rmd
index 3579eb73..66470b03 100644
--- a/README.Rmd
+++ b/README.Rmd
@@ -107,10 +107,10 @@ So far, so good. But where `plot2` starts to diverge from its base counterpart i
with respect to grouped data. In particular, `plot2` allows you to characterize
groups using the `by` argument.^[At this point, experienced base plot users
might protest that you _can_ colour by groups using the `col` argument, e.g.
-`plot(airquality$Day, airquality$Temp, col = airquality$Month)`. This is true,
+`with(airquality, plot(Day, Temp, col = Month))`. This is true,
but there are several limitations. First, you don't get an automatic legend.
-Second, the base `plot` formula method doesn't specify the grouping within the
-formula itself (not a deal-breaker, but not particularly consistent in my view).
+Second, the base `plot.formula` method doesn't specify the grouping within the
+formula itself (not a deal-breaker, but not particularly consistent either).
Third, and perhaps most importantly, this grouping doesn't carry over to line
plots (i.e., type="l"). Instead, you have to transpose your data and use
`matplot`. See
@@ -118,7 +118,9 @@ plots (i.e., type="l"). Instead, you have to transpose your data and use
old StackOverflow thread for a longer discussion.]
```{r by}
-plot2(airquality$Day, airquality$Temp, by = airquality$Month)
+# plot2(airquality$Day, airquality$Temp, by = airquality$Month) # same as below
+with(airquality, plot2(Day, Temp, by = Month))
+
```
An even more convenient approach is to use the equivalent formula syntax. Just
@@ -166,7 +168,29 @@ plot2(
)
```
-In all of the above cases, you will have noticed that we get an automatic
+On the subject of group colours, these are easily customized via the `palette`
+argument. The default group colours are inherited from either the "R4" or
+"Viridis" palettes, depending on the number of groups. However, all of the many
+palettes listed by `palette.pals()` and `hcl.pals()` are supported as
+convenience strings.^[See the accompanying help pages of those two functions
+for more details on the available palettes, or read the
+[article](https://arxiv.org/pdf/2303.04918.pdf) by Achim Zeileis and Paul
+Murrell.] For example:
+
+```{r palette_tableau}
+plot2(
+ Temp ~ Day | Month,
+ data = airquality,
+ type = "l",
+ palette = "Tableau 10" # or "ggplot2", "Okabe-Ito", "Set 2", "Harmonic", etc.
+)
+```
+
+Beyond these convenience strings, users can also supply a valid
+palette-generating function for finer control over transparency, colour order,
+and so forth. We'll see a demonstration of this further below.
+
+In all of the preceding plots, you will have noticed that we get an automatic
legend. The legend position and look can be customized using appropriate
arguments. You can change (or turn off) the legend title and bounding box,
switch the direction of the legend text, etc. Below, we particularly draw your
@@ -187,29 +211,12 @@ Note that legend position keywords without the exclamation point (i.e., for
inside the plot area) should still as per normal. Grouped density plot example:
```{r desnity_topright}
-plot2(
- density(airquality$Temp),
- by = airquality$Month,
+with(airquality, plot2(
+ density(Temp),
+ by = Month,
legend.position = "topright",
legend.args = list(title = "Month", bty="o")
-)
-```
-
-Colour palettes can be customized easily via the `palette` argument. The default
-group colours are inherited from either the "Okabe-Ito" or "Viridis" palettes,
-depending on the number of groups. However, all palettes listed by
-`palette.pals()` and `hcl.pals()` are supported.^[See the accompanying help
-pages of those two functions for more details, or read the
-[article](https://arxiv.org/pdf/2303.04918.pdf) by Achim Zeileis and Paul
-Murrell.] Simply pass on an appropriate palette name as a string.
-
-```{r palette_tableau}
-plot2(
- Temp ~ Day | Month,
- data = airquality,
- type = "l",
- palette = "Tableau 10"
-)
+))
```
Customizing your plots further is straightforward, whether that is done by
diff --git a/README.md b/README.md
index 5acca6c5..a18af3b3 100644
--- a/README.md
+++ b/README.md
@@ -110,7 +110,8 @@ counterpart is with respect to grouped data. In particular, `plot2`
allows you to characterize groups using the `by` argument.[^1]
``` r
-plot2(airquality$Day, airquality$Temp, by = airquality$Month)
+# plot2(airquality$Day, airquality$Temp, by = airquality$Month) # same as below
+with(airquality, plot2(Day, Temp, by = Month))
```
@@ -169,7 +170,28 @@ plot2(
-In all of the above cases, you will have noticed that we get an
+On the subject of group colours, these are easily customized via the
+`palette` argument. The default group colours are inherited from either
+the “R4” or “Viridis” palettes, depending on the number of groups.
+However, all of the many palettes listed by `palette.pals()` and
+`hcl.pals()` are supported as convenience strings.[^2] For example:
+
+``` r
+plot2(
+ Temp ~ Day | Month,
+ data = airquality,
+ type = "l",
+ palette = "Tableau 10" # or "ggplot2", "Okabe-Ito", "Set 2", "Harmonic", etc.
+)
+```
+
+
+
+Beyond these convenience strings, users can also supply a valid
+palette-generating function for finer control over transparency, colour
+order, and so forth. We’ll see a demonstration of this further below.
+
+In all of the preceding plots, you will have noticed that we get an
automatic legend. The legend position and look can be customized using
appropriate arguments. You can change (or turn off) the legend title and
bounding box, switch the direction of the legend text, etc. Below, we
@@ -194,33 +216,16 @@ for inside the plot area) should still as per normal. Grouped density
plot example:
``` r
-plot2(
- density(airquality$Temp),
- by = airquality$Month,
+with(airquality, plot2(
+ density(Temp),
+ by = Month,
legend.position = "topright",
legend.args = list(title = "Month", bty="o")
-)
+))
```
-Colour palettes can be customized easily via the `palette` argument. The
-default group colours are inherited from either the “Okabe-Ito” or
-“Viridis” palettes, depending on the number of groups. However, all
-palettes listed by `palette.pals()` and `hcl.pals()` are supported.[^2]
-Simply pass on an appropriate palette name as a string.
-
-``` r
-plot2(
- Temp ~ Day | Month,
- data = airquality,
- type = "l",
- palette = "Tableau 10"
-)
-```
-
-
-
Customizing your plots further is straightforward, whether that is done
by changing global parameters or invoking `plot2` arguments. Here’s a
quick penultimate example, where we change our point character and font
@@ -288,17 +293,18 @@ is expensive (e.g., an R application running in a browser via
[^1]: At this point, experienced base plot users might protest that you
*can* colour by groups using the `col` argument, e.g.
- `plot(airquality$Day, airquality$Temp, col = airquality$Month)`.
- This is true, but there are several limitations. First, you don’t
- get an automatic legend. Second, the base `plot` formula method
- doesn’t specify the grouping within the formula itself (not a
- deal-breaker, but not particularly consistent in my view). Third,
- and perhaps most importantly, this grouping doesn’t carry over to
- line plots (i.e., type=“l”). Instead, you have to transpose your
- data and use `matplot`. See
+ `with(airquality, plot(Day, Temp, col = Month))`. This is true, but
+ there are several limitations. First, you don’t get an automatic
+ legend. Second, the base `plot.formula` method doesn’t specify the
+ grouping within the formula itself (not a deal-breaker, but not
+ particularly consistent either). Third, and perhaps most
+ importantly, this grouping doesn’t carry over to line plots (i.e.,
+ type=“l”). Instead, you have to transpose your data and use
+ `matplot`. See
[this](https://stackoverflow.com/questions/10519873/how-to-create-a-line-plot-with-groups-in-base-r-without-loops)
old StackOverflow thread for a longer discussion.
[^2]: See the accompanying help pages of those two functions for more
- details, or read the [article](https://arxiv.org/pdf/2303.04918.pdf)
- by Achim Zeileis and Paul Murrell.
+ details on the available palettes, or read the
+ [article](https://arxiv.org/pdf/2303.04918.pdf) by Achim Zeileis and
+ Paul Murrell.
diff --git a/inst/tinytest/_tinysnapshot/aesthetics_by.svg b/inst/tinytest/_tinysnapshot/aesthetics_by.svg
index 22d8b8b9..4b1a60a5 100644
--- a/inst/tinytest/_tinysnapshot/aesthetics_by.svg
+++ b/inst/tinytest/_tinysnapshot/aesthetics_by.svg
@@ -22,17 +22,17 @@
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
Month
5
6
@@ -128,277 +128,277 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/inst/tinytest/_tinysnapshot/aesthetics_by_par.svg b/inst/tinytest/_tinysnapshot/aesthetics_by_par.svg
index 90fc9cfb..9506fb23 100644
--- a/inst/tinytest/_tinysnapshot/aesthetics_by_par.svg
+++ b/inst/tinytest/_tinysnapshot/aesthetics_by_par.svg
@@ -22,15 +22,15 @@
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
Month
5
6
@@ -126,215 +126,215 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/inst/tinytest/_tinysnapshot/aesthetics_by_recycle.svg b/inst/tinytest/_tinysnapshot/aesthetics_by_recycle.svg
index b5706e48..291e6c48 100644
--- a/inst/tinytest/_tinysnapshot/aesthetics_by_recycle.svg
+++ b/inst/tinytest/_tinysnapshot/aesthetics_by_recycle.svg
@@ -22,16 +22,16 @@
-
-
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+
+
Month
5
6
@@ -127,245 +127,245 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/inst/tinytest/_tinysnapshot/aesthetics_by_type_l.svg b/inst/tinytest/_tinysnapshot/aesthetics_by_type_l.svg
index 97085e7f..89ae201a 100644
--- a/inst/tinytest/_tinysnapshot/aesthetics_by_type_l.svg
+++ b/inst/tinytest/_tinysnapshot/aesthetics_by_type_l.svg
@@ -22,10 +22,10 @@
-
-
-
-
+
+
+
+
Month
5
6
@@ -65,10 +65,10 @@
-
-
-
-
+
+
+
+
diff --git a/inst/tinytest/_tinysnapshot/aesthetics_type_b.svg b/inst/tinytest/_tinysnapshot/aesthetics_type_b.svg
index 2b39060d..d1bd77fa 100644
--- a/inst/tinytest/_tinysnap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_tinysnapshot/aesthetics_type_l.svg b/inst/tinytest/_tinysnapshot/aesthetics_type_l.svg
index 86af0716..7d3ae2af 100644
--- a/inst/tinytest/_tinysnapshot/aesthetics_type_l.svg
+++ b/inst/tinytest/_tinysnapshot/aesthetics_type_l.svg
@@ -22,10 +22,10 @@
-
-
-
-
+
+
+
+
Month
5
6
@@ -65,10 +65,10 @@
-
-
-
-
+
+
+
+
diff --git a/inst/tinytest/_tinysnapshot/density_factor.svg b/inst/tinytest/_tinysnapshot/density_factor.svg
index 0189dccf..0fad9053 100644
--- a/inst/tinytest/_tinysnapshot/density_factor.svg
+++ b/inst/tinytest/_tinysnapshot/density_factor.svg
@@ -22,8 +22,8 @@
-
-
+
+
iris$Species
setosa
versicolor
@@ -67,8 +67,8 @@
-
-
+
+
diff --git a/inst/tinytest/_tinysnapshot/density_numeric.svg b/inst/tinytest/_tinysnapshot/density_numeric.svg
index 67e91b61..7b3ee440 100644
--- a/inst/tinytest/_tinysnapshot/density_numeric.svg
+++ b/inst/tinytest/_tinysnapshot/density_numeric.svg
@@ -22,7 +22,7 @@
-
+
mtcars$am
0
1
@@ -55,7 +55,7 @@
-
+
diff --git a/inst/tinytest/_tinysnapshot/par_restore_bottom.svg b/inst/tinytest/_tinysnapshot/par_restore_bottom.svg
index 01bc4d3e..ab9af457 100644
--- a/inst/tinytest/_tinysnapshot/par_restore_bottom.svg
+++ b/inst/tinytest/_tinysnapshot/par_restore_bottom.svg
@@ -23,8 +23,8 @@
-
-
+
+
Species
setosa
versicolor
@@ -128,106 +128,106 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/inst/tinytest/_tinysnapshot/readme_basetheme_royal.svg b/inst/tinytest/_tinysnapshot/readme_basetheme_royal.svg
deleted file mode 100644
index ab10cbea..00000000
--- a/inst/tinytest/_tinysnapshot/readme_basetheme_royal.svg
+++ /dev/null
@@ -1,359 +0,0 @@
-
-
diff --git a/inst/tinytest/_tinysnapshot/readme_by.svg b/inst/tinytest/_tinysnapshot/readme_by.svg
index beef4638..32cb9471 100644
--- a/inst/tinytest/_tinysnapshot/readme_by.svg
+++ b/inst/tinytest/_tinysnapshot/readme_by.svg
@@ -22,10 +22,10 @@
-
-
-
-
+
+
+
+
airquality$Month
5
6
@@ -95,128 +95,128 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/inst/tinytest/_tinysnapshot/readme_density_topright.svg b/inst/tinytest/_tinysnapshot/readme_density_topright.svg
index 8eaf86c1..c5d80f1c 100644
--- a/inst/tinytest/_tinysnapshot/readme_density_topright.svg
+++ b/inst/tinytest/_tinysnapshot/readme_density_topright.svg
@@ -23,10 +23,10 @@
-
-
-
-
+
+
+
+
Month
5
6
@@ -66,10 +66,10 @@
-
-
-
-
+
+
+
+
density.default(x = airquality$Temp)
diff --git a/inst/tinytest/_tinysnapshot/readme_formula.svg b/inst/tinytest/_tinysnapshot/readme_formula.svg
index 233490b4..032cf32c 100644
--- a/inst/tinytest/_tinysnapshot/readme_formula.svg
+++ b/inst/tinytest/_tinysnapshot/readme_formula.svg
@@ -22,10 +22,10 @@
-
-
-
-
+
+
+
+
Month
5
6
@@ -95,128 +95,128 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/inst/tinytest/_tinysnapshot/readme_legend_bottom.svg b/inst/tinytest/_tinysnapshot/readme_legend_bottom.svg
index 9b4e9c40..4548b005 100644
--- a/inst/tinytest/_tinysnapshot/readme_legend_bottom.svg
+++ b/inst/tinytest/_tinysnapshot/readme_legend_bottom.svg
@@ -23,10 +23,10 @@
-
-
-
-
+
+
+
+
Month of the year
5
6
@@ -66,10 +66,10 @@
-
-
-
-
+
+
+
+
diff --git a/inst/tinytest/_tinysnapshot/readme_pch_16.svg b/inst/tinytest/_tinysnapshot/readme_pch_16.svg
index f8baf6ac..b791d939 100644
--- a/inst/tinytest/_tinysnapshot/readme_pch_16.svg
+++ b/inst/tinytest/_tinysnapshot/readme_pch_16.svg
@@ -22,10 +22,10 @@
-
-
-
-
+
+
+
+
Month
5
6
@@ -95,128 +95,128 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/inst/tinytest/_tinysnapshot/readme_type_l.svg b/inst/tinytest/_tinysnapshot/readme_type_l.svg
index 86af0716..7d3ae2af 100644
--- a/inst/tinytest/_tinysnapshot/readme_type_l.svg
+++ b/inst/tinytest/_tinysnapshot/readme_type_l.svg
@@ -22,10 +22,10 @@
-
-
-
-
+
+
+
+
Month
5
6
@@ -65,10 +65,10 @@
-
-
-
-
+
+
+
+
diff --git a/inst/tinytest/_tinysnapshot/type_c_group.svg b/inst/tinytest/_tinysnapshot/type_c_group.svg
index f7e4f60d..3b8cc488 100644
--- a/inst/tinytest/_tinysnapshot/type_c_group.svg
+++ b/inst/tinytest/_tinysnapshot/type_c_group.svg
@@ -22,10 +22,10 @@
-
-
-
-
+
+
+
+
Month
5
6
@@ -90,93 +90,93 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/inst/tinytest/_tinysnapshot/type_cap_s_group.svg b/inst/tinytest/_tinysnapshot/type_cap_s_group.svg
index 26b0a3e0..5370bc57 100644
--- a/inst/tinytest/_tinysnapshot/type_cap_s_group.svg
+++ b/inst/tinytest/_tinysnapshot/type_cap_s_group.svg
@@ -22,10 +22,10 @@
-
-
-
-
+
+
+
+
Month
5
6
@@ -65,10 +65,10 @@
-
-
-
-
+
+
+
+
diff --git a/inst/tinytest/_tinysnapshot/type_h_group.svg b/inst/tinytest/_tinysnapshot/type_h_group.svg
index 4d938fff..5eafe98e 100644
--- a/inst/tinytest/_tinysnapshot/type_h_group.svg
+++ b/inst/tinytest/_tinysnapshot/type_h_group.svg
@@ -22,10 +22,10 @@
-
-
-
-
+
+
+
+
Month
5
6
@@ -95,128 +95,128 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/inst/tinytest/_tinysnapshot/type_s_group.svg b/inst/tinytest/_tinysnapshot/type_s_group.svg
index b225086b..50ad7a18 100644
--- a/inst/tinytest/_tinysnapshot/type_s_group.svg
+++ b/inst/tinytest/_tinysnapshot/type_s_group.svg
@@ -22,10 +22,10 @@
-
-
-
-
+
+
+
+
Month
5
6
@@ -65,10 +65,10 @@
-
-
-
-
+
+
+
+
diff --git a/man/figures/README-by-1.png b/man/figures/README-by-1.png
index 93eb6047..f54754ce 100644
Binary files a/man/figures/README-by-1.png and b/man/figures/README-by-1.png differ
diff --git a/man/figures/README-desnity_topright-1.png b/man/figures/README-desnity_topright-1.png
index 7fb87570..7e33b727 100644
Binary files a/man/figures/README-desnity_topright-1.png and b/man/figures/README-desnity_topright-1.png differ
diff --git a/man/figures/README-formula-1.png b/man/figures/README-formula-1.png
index ba734a25..f54754ce 100644
Binary files a/man/figures/README-formula-1.png and b/man/figures/README-formula-1.png differ
diff --git a/man/figures/README-legend_bottom-1.png b/man/figures/README-legend_bottom-1.png
index bb0ff087..5f3908a3 100644
Binary files a/man/figures/README-legend_bottom-1.png and b/man/figures/README-legend_bottom-1.png differ
diff --git a/man/figures/README-pch_16-1.png b/man/figures/README-pch_16-1.png
index 3e28eb15..550b4f22 100644
Binary files a/man/figures/README-pch_16-1.png and b/man/figures/README-pch_16-1.png differ
diff --git a/man/figures/README-type_l-1.png b/man/figures/README-type_l-1.png
index d0d60950..bab40a71 100644
Binary files a/man/figures/README-type_l-1.png and b/man/figures/README-type_l-1.png differ
diff --git a/man/plot2.Rd b/man/plot2.Rd
index 3c8678f7..47548b5b 100644
--- a/man/plot2.Rd
+++ b/man/plot2.Rd
@@ -146,10 +146,13 @@ replaces the `panel.first` and `panel.last` arguments from base `plot()`
and tries to make the process more seemless with better default behaviour.}
\item{palette}{one of the following options:
-- NULL (default), in which case R's default colour palette will be used.
-- A string corresponding to one of the palettes in either `palette.pals()`
-`hcl.pals()`. These can be case-insensitive (e.g., "viridis" and "Viridis"
-are both valid).
+- NULL (default), in which case the palette will be determined by the
+number of groups. If this number is equal to 8 or less, then R's default
+("R4") colour palette will be used. For larger group numbers, the
+"Viridis" palette will be used instead.
+- A convenience string corresponding to one of the many palettes listed by
+either `palette.pals()` or `hcl.pals()`. Note that the string can be
+case-insensitive (e.g., "Okabe-Ito" and "okabe-ito" are both valid).
- A palette-generating function. This can be "bare" (e.g.,
`palette.colors`) or "closed" with a set of named arguments (e.g.,
`palette.colors(palette = "Okabe-Ito", alpha = 0.5)`). Note that any
@@ -274,9 +277,11 @@ plot2(
legend.position = "topright", legend.args = list(bty="o", title = "Month")
)
-# The default group colours are inherited from either the "Okabe-Ito" or
-# "Viridis" palettes, depending on the number of groups. However, all
-# palettes listed by `palette.pals()` and `hcl.pals()` are supported.
+# The default group colours are inherited from either the "R4" or "Viridis"
+# palettes, depending on the number of groups. However, all palettes listed
+# by `palette.pals()` and `hcl.pals()` are supported as convenience strings,
+# or users can supply a valid palette-generating function for finer control
+# over transparency etc.
plot2(
Temp ~ Day | Month,