diff --git a/R/facet.R b/R/facet.R
index d8056a01..281fbec1 100644
--- a/R/facet.R
+++ b/R/facet.R
@@ -183,6 +183,9 @@ draw_facet_window = function(grid, ...) {
# extra whitespace bump on the y axis
# yaxl = axTicks(2)
yaxl = axisTicks(usr = extendrange(ylim, f = 0.04), log = par("ylog"))
+ ## overrides for ridge and spineplot types
+ if (type == "ridge") yaxl = levels(y)
+ if (type == "spineplot") yaxl = ylabs
# whtsbp = grconvertX(max(strwidth(yaxl, "figure")), from = "nfc", to = "lines") - 1
whtsbp = grconvertX(max(strwidth(yaxl, "figure")), from = "nfc", to = "lines") - grconvertX(0, from = "nfc", to = "lines") - 1
if (whtsbp > 0) {
@@ -236,10 +239,14 @@ draw_facet_window = function(grid, ...) {
# Dynamic plot margin adjustments
omar = par("mar")
omar = omar - c(0, 0, 1, 0) # reduce top whitespace since no facet (title)
+ if (type == "spineplot") omar[4] = 2.1 # catch for spineplot RHS axis labs
if (par("las") %in% 1:2) {
# extra whitespace bump on the y axis
# yaxl = axTicks(2)
yaxl = axisTicks(usr = extendrange(ylim, f = 0.04), log = par("ylog"))
+ ## overrides for ridge and spineplot types
+ if (type == "ridge") yaxl = levels(y)
+ if (type == "spineplot") yaxl = ylabs
# whtsbp = grconvertX(max(strwidth(yaxl, "figure")), from = "nfc", to = "lines") - 1
whtsbp = grconvertX(max(strwidth(yaxl, "figure")), from = "nfc", to = "lines") - grconvertX(0, from = "nfc", to = "lines") - 1
if (whtsbp > 0) {
diff --git a/R/tinytheme.R b/R/tinytheme.R
index 0ebd8aa2..3240a5ee 100644
--- a/R/tinytheme.R
+++ b/R/tinytheme.R
@@ -44,7 +44,6 @@
#' Known current limitations include:
#'
#' - Themes do not work well when `legend = "top!"`.
-#' - Themes do not play nicely with some complex plot types, particularly `"spineplot"` and `"ridge"`.
#' - Dynamic margin spacing does not account for multi-line strings (e.g., axes
#' or main titles that contain "\\n").
#'
diff --git a/R/type_ridge.R b/R/type_ridge.R
index 77803f07..b60bc3f6 100644
--- a/R/type_ridge.R
+++ b/R/type_ridge.R
@@ -318,7 +318,9 @@ data_ridge = function(bw = "nrd0", adjust = 1, kernel = "gaussian", n = 512,
dotspal = list(...)[["palette"]]
palette = if (!is.null(dotspal)) dotspal else gradient
gradient = TRUE
- if (isTRUE(palette)) palette = "viridis"
+ if (isTRUE(palette)) {
+ palette = if (!is.null(.tpar[["palette.sequential"]])) .tpar[["palette.sequential"]] else "viridis"
+ }
if (length(palette) > 1L || !is.character(palette)) {
## color vector already given
@@ -380,7 +382,8 @@ draw_ridge = function() {
d = data.frame(x = ix, y = iy, ymin = iymin, ymax = iymax)
dsplit = split(d, d$y)
if (is.null(ibg)) {
- ibg = if (isTRUE(type_info[["fill_by"]])) seq_palette(icol, n = 2)[2] else "gray"
+ default_bg = if (!is.null(.tpar[["palette.qualitative"]])) seq_palette(by_col(), n = 2)[2] else "gray"
+ ibg = if (isTRUE(type_info[["fill_by"]])) seq_palette(icol, n = 2)[2] else default_bg
}
if (!is.null(type_info[["alpha"]]) && is.null(type_info[["palette"]])) {
ibg = adjustcolor(ibg, alpha.f = type_info[["alpha"]])
diff --git a/R/type_spineplot.R b/R/type_spineplot.R
index 5997e9d4..f2b0f6d1 100644
--- a/R/type_spineplot.R
+++ b/R/type_spineplot.R
@@ -215,7 +215,7 @@ data_spineplot = function(off = NULL, breaks = NULL, ylevels = ylevels, xaxlabel
if (isTRUE(y_by)) datapoints$by = rep(yaxlabels, length.out = nrow(datapoints))
## grayscale flag
- grayscale = length(unique(datapoints[["by"]])) == 1 && is.null(palette)
+ grayscale = length(unique(datapoints[["by"]])) == 1 && is.null(palette) && is.null(.tpar[["palette.qualitative"]])
out = list(
x = c(datapoints$xmin, datapoints$xmax),
@@ -235,6 +235,7 @@ data_spineplot = function(off = NULL, breaks = NULL, ylevels = ylevels, xaxlabel
yaxt = "n",
xaxs = "i",
yaxs = "i",
+ ylabs = yaxlabels,
type_info = list(
off = off,
x.categorical = x.categorical,
diff --git a/inst/tinytest/_tinysnapshot/tinytheme_dynamic_clean_ridge.svg b/inst/tinytest/_tinysnapshot/tinytheme_dynamic_clean_ridge.svg
new file mode 100644
index 00000000..fbfd7447
--- /dev/null
+++ b/inst/tinytest/_tinysnapshot/tinytheme_dynamic_clean_ridge.svg
@@ -0,0 +1,83 @@
+
+
diff --git a/inst/tinytest/_tinysnapshot/tinytheme_dynamic_clean_spineplot.svg b/inst/tinytest/_tinysnapshot/tinytheme_dynamic_clean_spineplot.svg
new file mode 100644
index 00000000..6ca6e609
--- /dev/null
+++ b/inst/tinytest/_tinysnapshot/tinytheme_dynamic_clean_spineplot.svg
@@ -0,0 +1,126 @@
+
+
diff --git a/inst/tinytest/test-tinytheme.R b/inst/tinytest/test-tinytheme.R
index 361f660e..5f5d5b60 100644
--- a/inst/tinytest/test-tinytheme.R
+++ b/inst/tinytest/test-tinytheme.R
@@ -70,6 +70,28 @@ tinytheme("dark")
f()
expect_snapshot_plot(f, label = "tinytheme_dynamic_dark_facet")
+# ridge and spineplot types (req's extra steps b/c of tinyAxis logic)
+
+tinytheme('clean')
+
+f = function() {
+ tinyplot(
+ Species ~ Petal.Length, data = iris, type = "ridge",
+ main = "Dynamic plot adjustment and whitespace reduction",
+ sub = "Ridge plot version"
+ )
+}
+expect_snapshot_plot(f, label = "tinytheme_dynamic_clean_ridge")
+
+f = function() {
+ tinyplot(
+ Species ~ Petal.Length, data = iris, type = "spineplot",
+ main = "Dynamic plot adjustment and whitespace reduction",
+ sub = "Spineplot version"
+ )
+}
+expect_snapshot_plot(f, label = "tinytheme_dynamic_clean_spineplot")
+
#
## reset
diff --git a/man/tinytheme.Rd b/man/tinytheme.Rd
index 6568db47..fce748f6 100644
--- a/man/tinytheme.Rd
+++ b/man/tinytheme.Rd
@@ -59,7 +59,6 @@ behaviour to our GitHub repo:
Known current limitations include:
\itemize{
\item Themes do not work well when \code{legend = "top!"}.
-\item Themes do not play nicely with some complex plot types, particularly \code{"spineplot"} and \code{"ridge"}.
\item Dynamic margin spacing does not account for multi-line strings (e.g., axes
or main titles that contain "\\n").
}