Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tinytheme("ridge(2)") #302

Merged
merged 13 commits into from
Feb 4, 2025
Merged

tinytheme("ridge(2)") #302

merged 13 commits into from
Feb 4, 2025

Conversation

grantmcdermott
Copy link
Owner

This PR adds a dedicated "ridge" theme, as well as a "ridge2" variation. Both themes are built off of "clean(2)" and key features includes: horizontal y-axis labels (with slight vertical adjustment), dynamic plot margins, and solid horizontal grid lines for each group along the y-axis. The latter feature required a bit of trickery b/c of tinyAxis() and grid() constraints, but this actually works well b/c it only applies to type_ridge().

I also fixed some other, outstanding issues related to type_ridge() while I was at it and reworked the documentation a bit.

Quick examples:

aq = transform(
  airquality,
  Month = factor(month.abb[Month], levels = month.abb[5:9]),
  Late = ifelse(Day > 15, "Late", "Early")
)

library(tinyplot)

tinytheme('ridge')
plt(Month ~ Temp, data = aq, type = "ridge")

tinytheme('ridge2')
plt(Month ~ Temp, data = aq, type = "ridge")

plt(Month ~ Temp | Month, data = aq, type = "ridge")

tinytheme('ridge')
plt(Month ~ Ozone, facet = ~ Late, data = aq, type = type_ridge(gradient = TRUE))

tinytheme()

Created on 2025-02-04 with reprex v2.1.1

@grantmcdermott
Copy link
Owner Author

One more MWE. Replicating this cool ggridges example used to be a minor headache because of misaligned grid lines (example). But it now looks good out of the gate with the new theme(s).

data("lincoln_weather", package = "ggridges")

tinytheme('ridge2')
plt(Month ~ `Max Temperature [F]`, data = lincoln_weather,
    type = type_ridge(gradient = TRUE, scale = 3))

@grantmcdermott grantmcdermott merged commit de6ecf5 into main Feb 4, 2025
3 checks passed
@grantmcdermott grantmcdermott deleted the tinytheme_ridge branch February 4, 2025 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant