Skip to content

Da Big ojoThemes PR #2

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

Merged
merged 27 commits into from
Dec 5, 2024
Merged

Da Big ojoThemes PR #2

merged 27 commits into from
Dec 5, 2024

Conversation

andrewjbe
Copy link
Contributor

I accidentally committed a few things to main at first, but this PR will track my rewrites / implementations of theme_ojo(), theme_okpi(), and hopefully also theme_tok().

@andrewjbe andrewjbe self-assigned this Oct 30, 2024
@andrewjbe andrewjbe changed the title exported ojo_caption functions Da Big ojoThemes PR Oct 31, 2024
DESCRIPTION Outdated
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added ggplot2 and showtext to depends, this ensures the fonts can be handled by showtext and removes the need to run library(ggplot2) before attaching this package.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was actually wrong lol, they're all in imports now

#' @family tok palettes
#' @rdname tok_palettes
#' @export
palette_tok_main <- c(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kinda sucks and I just threw it together to have something in there. The whole TOK theme is kinda similar, I just wanted to get the bones in place

R/geoms.R Outdated

setup_data = function(data, params) {
data$width <- data$width %||%
params$width %||% (resolution(data$x, FALSE) * 0.7) # Set to 70% of resolution rather than default 90%
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Literally the only difference from the default GeomCol ggproto is that this is 0.7 and not 0.9

position = position,
show.legend = show.legend,
inherit.aes = inherit.aes,
params = list(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where we could change the default geom color, etc. too if we wanted.

#' @param ... other arguments passed to \code{geom_line()}
#' @export
geom_line <- function(mapping = NULL, size = 1, ...) {
ggplot2::geom_line(mapping = mapping, size = size, ...)
geom_line <- function(mapping = NULL, linewidth = 1.5, ...) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't require a whole new ggproto object because the linewidth doesn't cause the same data resolution issues as the col width.

#' @param base_line_size The base line size to use; 0.5 is the default.
#' @param base_rect_size The base rect size to use; 0.5 is the default.
#' @export
theme_ojo <- function(base_size = 14,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I broke this out from theme_ojo_base() like we discussed @brancengregory

@andrewjbe
Copy link
Contributor Author

I'm not quite ready to think about merging this yet, but I've got a functional version of the 3 main themes in there (even though the TOK one looks like shit). I'll let y'all know when I'm ready for a final review!

R/zzz.R Outdated
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need any of this in zzz.R, I did specify in the DESCRIPTION that we need version 3.0.0 of ggplot2 though

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could be wrong though, I'm not 100% sure what it was doing

@andrewjbe andrewjbe marked this pull request as ready for review November 7, 2024 21:08
@andrewjbe andrewjbe linked an issue Nov 7, 2024 that may be closed by this pull request
@brancengregory
Copy link
Member

This is all ready for review now @anthonyokc

}

# add base_family font to text and label geoms ---------------------------
ggplot2::update_geom_defaults("text", list(family = base_family))
ggplot2::update_geom_defaults("label", list(family = base_family))
ggplot2::update_geom_defaults("text_repel", list(family = base_family))
ggplot2::update_geom_defaults("label_repel", list(family = base_family))
# ggplot2::update_geom_defaults("text_repel", list(family = base_family)) # Keep ggrepel in this?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason not to keep it? Does it require us having ggrepel installed or anything? If not I'd keep it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it should require ggrepel if I'm understanding correctly, this should just do nothing if it's not installed I think.

@anthonyokc
Copy link
Member

Made some changes to the spacing and gridlines for the themes

image
image

I'd still like to fix the spacing between the legend items (see how the text for a legend item is too close to the box to the right of it), so might get to that quickly tomorrow (or someone else can if they have the time, you'd probably just mess with the legend.key.spacing.x).

@andrewjbe
Copy link
Contributor Author

I think I fixed your last point about horizontal spacing on the legend @anthonyokc

@andrewjbe andrewjbe merged commit 2e5edf2 into main Dec 5, 2024
1 check passed
@brancengregory brancengregory deleted the andrew-overhaul branch April 20, 2025 06:06
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.

ojo_theme(), theming function for ggplot2 plots
3 participants