Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@ Suggests:
Depends:
R (>= 4.0.0)
Imports:
ggplot2 (>= 3.4.0),
ggplot2 (>= 3.5.2),
grDevices,
grid,
scales,
extrafont,
tools,
magrittr,
gdtools,
utils
RoxygenNote: 7.3.2
Roxygen: list(markdown = TRUE)
2 changes: 0 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,10 @@ export(theme_ipsum_pub)
export(theme_ipsum_rc)
export(theme_modern_rc)
export(update_geom_font_defaults)
import(extrafont)
import(ggplot2)
import(grDevices)
import(grid)
import(scales)
importFrom(gdtools,set_dummy_conf)
importFrom(ggplot2,scale_color_gradientn)
importFrom(ggplot2,scale_color_manual)
importFrom(ggplot2,scale_fill_gradientn)
Expand Down
103 changes: 12 additions & 91 deletions R/bit12.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' distinct colors that work well for categorical data while maintaining good contrast
#' and accessibility.
#'
#' @name bit12
#' @name bit12_scale
#' @details
#' The package provides several types of scales:
#' * Discrete scales for categorical data
Expand All @@ -26,9 +26,10 @@
#' * Cobalt: Deep blue for stability and reliability
#' * Violet: Purple for creative and distinctive elements
#'
#' @param ... Additional arguments passed to scale_color_manual() or scale_fill_manual()
#' @param ... Additional arguments passed to scale_color_manual(), scale_fill_manual(), scale_color_gradientn(), or scale_fill_gradientn()
#' @param palette For continuous scales, the name of the color palette to use
#' (one of "plum", "rose", "coral", "apricot", "lemon", "lime", "mint", "teal", "sky", "azure", "cobalt", "violet")
#' @param direction Sets the direction of the color scale (1 = default, -1 = reversed)
#'
#' @return A ggplot2 scale object
#'
Expand Down Expand Up @@ -69,30 +70,14 @@ bit12 <- c(
violet = "#639"
)

#' Discrete Color Scale Using Bit12 Colors
#'
#' @param ... Additional arguments passed to scale_color_manual()
#' @return A discrete ggplot2 color scale
#' @name bit12_scale
#' @export
#' @examples
#' library(ggplot2)
#' ggplot(mtcars, aes(wt, mpg, color = factor(cyl))) +
#' geom_point() +
#' scale_color_bit12()
scale_color_bit12 <- function(...) {
scale_color_manual(values = unname(bit12), ...)
}

#' Discrete Fill Scale Using Bit12 Colors
#'
#' @param ... Additional arguments passed to scale_fill_manual()
#' @return A discrete ggplot2 fill scale
#' @name bit12_scale
#' @export
#' @examples
#' library(ggplot2)
#' ggplot(mtcars, aes(factor(cyl), fill = factor(cyl))) +
#' geom_bar() +
#' scale_fill_bit12()
scale_fill_bit12 <- function(...) {
scale_fill_manual(values = unname(bit12), ...)
}
Expand Down Expand Up @@ -153,35 +138,17 @@ create_continuous_scale <- function(colors) {
colorRampPalette(colors)
}

#' Continuous Color Scale Using Bit12 Colors
#'
#' @param palette Name of the color palette to use ("plum", "rose", "coral", "apricot", "lemon", "lime", "mint", "teal", "sky", "azure", "cobalt", "violet")
#' @param ... Additional arguments passed to scale_color_gradientn()
#' @return A continuous ggplot2 color scale
#' @name bit12_scale
#' @export
#' @examples
#' library(ggplot2)
#' ggplot(faithfuld, aes(waiting, eruptions, color = density)) +
#' geom_point() +
#' scale_color_bit12_continuous(palette = "azure")
scale_color_bit12_continuous <- function(palette = "azure", ...) {
scale_color_gradientn(
colors = create_continuous_scale(bit12_extended[[palette]])(100),
...
)
}

#' Continuous Fill Scale Using Bit12 Colors
#'
#' @param palette Name of the color palette to use ("plum", "rose", "coral", "apricot", "lemon", "lime", "mint", "teal", "sky", "azure", "cobalt", "violet")
#' @param ... Additional arguments passed to scale_fill_gradientn()
#' @return A continuous ggplot2 fill scale
#' @name bit12_scale
#' @export
#' @examples
#' library(ggplot2)
#' ggplot(faithfuld, aes(waiting, eruptions, fill = density)) +
#' geom_tile() +
#' scale_fill_bit12_continuous(palette = "azure")
scale_fill_bit12_continuous <- function(palette = "azure", ...) {
scale_fill_gradientn(
colors = create_continuous_scale(
Expand All @@ -191,20 +158,8 @@ scale_fill_bit12_continuous <- function(palette = "azure", ...) {
)
}

#' Distiller Color Scale Using Bit12 Colors
#'
#' Creates a sequential color gradient based on a selected Bit12 color
#'
#' @param palette Name of the color palette to use ("plum", "rose", "coral", "apricot", "lemon", "lime", "mint", "teal", "sky", "azure", "cobalt", "violet")
#' @param direction Sets the direction of the color scale (1 = default, -1 = reversed)
#' @param ... Additional arguments passed to scale_color_gradientn()
#' @return A sequential ggplot2 color scale
#' @name bit12_scale
#' @export
#' @examples
#' library(ggplot2)
#' ggplot(faithfuld, aes(waiting, eruptions, color = density)) +
#' geom_point() +
#' scale_color_bit12_distiller(palette = "azure")
scale_color_bit12_distiller <- function(palette = "azure", direction = 1, ...) {
# Select colors from the palette for a light-to-dark gradient
if (direction == 1) {
Expand All @@ -219,20 +174,8 @@ scale_color_bit12_distiller <- function(palette = "azure", direction = 1, ...) {
)
}

#' Distiller Fill Scale Using Bit12 Colors
#'
#' Creates a sequential fill gradient based on a selected Bit12 color
#'
#' @param palette Name of the color palette to use ("plum", "rose", "coral", "apricot", "lemon", "lime", "mint", "teal", "sky", "azure", "cobalt", "violet")
#' @param direction Sets the direction of the color scale (1 = default, -1 = reversed)
#' @param ... Additional arguments passed to scale_fill_gradientn()
#' @return A sequential ggplot2 fill scale
#' @name bit12_scale
#' @export
#' @examples
#' library(ggplot2)
#' ggplot(faithfuld, aes(waiting, eruptions, fill = density)) +
#' geom_tile() +
#' scale_fill_bit12_distiller(palette = "azure")
scale_fill_bit12_distiller <- function(palette = "azure", direction = 1, ...) {
# Select colors from the palette for a light-to-dark gradient
if (direction == 1) {
Expand All @@ -247,19 +190,8 @@ scale_fill_bit12_distiller <- function(palette = "azure", direction = 1, ...) {
)
}

#' Distiller Color Scale Across All Bit12 Colors
#'
#' Creates a sequential color gradient using all colors from the Bit12 palette
#'
#' @param direction Sets the direction of the color scale (1 = default, -1 = reversed)
#' @param ... Additional arguments passed to scale_color_gradientn()
#' @return A sequential ggplot2 color scale
#' @name bit12_scale
#' @export
#' @examples
#' library(ggplot2)
#' ggplot(faithfuld, aes(waiting, eruptions, color = density)) +
#' geom_point() +
#' scale_color_bit12_spectrum()
scale_color_bit12_spectrum <- function(direction = 1, ...) {
# Use all colors from the palette
colors <- unname(bit12)
Expand All @@ -274,19 +206,8 @@ scale_color_bit12_spectrum <- function(direction = 1, ...) {
)
}

#' Distiller Fill Scale Across All Bit12 Colors
#'
#' Creates a sequential fill gradient using all colors from the Bit12 palette
#'
#' @param direction Sets the direction of the color scale (1 = default, -1 = reversed)
#' @param ... Additional arguments passed to scale_fill_gradientn()
#' @return A sequential ggplot2 fill scale
#' @name bit12_scale
#' @export
#' @examples
#' library(ggplot2)
#' ggplot(faithfuld, aes(waiting, eruptions, fill = density)) +
#' geom_tile() +
#' scale_fill_bit12_spectrum()
scale_fill_bit12_spectrum <- function(direction = 1, ...) {
# Use all colors from the palette
colors <- unname(bit12)
Expand All @@ -299,4 +220,4 @@ scale_fill_bit12_spectrum <- function(direction = 1, ...) {
colors = colors,
...
)
}
}
6 changes: 3 additions & 3 deletions R/check.r
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ gg_check <- function(gg, dict, ignore) {
if (missing(dict)) dict <- hunspell::dictionary("en_US")
if (missing(ignore)) ignore <- hunspell::en_stats

if (inherits(gg, "labels")) {
if (inherits(gg, "labels") || inherits(gg, "ggplot2::labels")) {
lbl <- gg
} else if ("labels" %in% names(gg)) {
lbl <- gg$labels
} else if (is_ggplot(gg)) {
lbl <- get_labs(gg)
} else {
return(gg)
}
Expand Down
2 changes: 1 addition & 1 deletion R/econ-sans.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' A precise & pristine [ggplot2] theme with opinionated defaults and an emphasis on typoghraphy
#' A precise & pristine [ggplot2][ggplot2][ggplot2::ggplot2] theme with opinionated defaults and an emphasis on typoghraphy
#'
#' You should [import_econ_sans()] first and install the fonts on your
#' system before trying to use this theme.
Expand Down
2 changes: 1 addition & 1 deletion R/goldmansans.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' A precise & pristine [ggplot2] theme with opinionated defaults and an emphasis on typoghraphy
#' A precise & pristine [ggplot2][ggplot2][ggplot2::ggplot2] theme with opinionated defaults and an emphasis on typoghraphy
#'
#' You should [import_goldman_sans()] first and install the fonts on your
#' system before trying to use this theme.
Expand Down
3 changes: 1 addition & 2 deletions R/hrbrthemes-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
#' @docType package
#' @author Bob Rudis (bob@@rud.is)
#' @keywords internal
#' @import ggplot2 grid scales extrafont grDevices
#' @import ggplot2 grid scales grDevices
#' @importFrom magrittr %>%
#' @importFrom gdtools set_dummy_conf
#' @importFrom tools file_path_sans_ext
#' @importFrom utils packageVersion compareVersion
"_PACKAGE"
Expand Down
2 changes: 1 addition & 1 deletion R/inter.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' A precise & pristine [ggplot2] theme with opinionated defaults and an emphasis on typoghraphy
#' A precise & pristine [ggplot2][ggplot2][ggplot2::ggplot2] theme with opinionated defaults and an emphasis on typoghraphy
#'
#' You should [import_inter()] first and install the fonts on your
#' system before trying to use this theme.
Expand Down
2 changes: 1 addition & 1 deletion R/plexsans.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' A precise & pristine [ggplot2] theme with opinionated defaults and an emphasis on typoghraphy
#' A precise & pristine [ggplot2][ggplot2][ggplot2::ggplot2] theme with opinionated defaults and an emphasis on typoghraphy
#'
#' You should [import_plex_sans()] first and install the fonts on your
#' system before trying to use this theme.
Expand Down
2 changes: 1 addition & 1 deletion R/public-sans.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' A precise & pristine [ggplot2] theme with opinionated defaults and an emphasis on typoghraphy
#' A precise & pristine [ggplot2][ggplot2][ggplot2::ggplot2] theme with opinionated defaults and an emphasis on typoghraphy
#'
#' You should [import_public_sans()] first and install the fonts on your
#' system before trying to use this theme.
Expand Down
2 changes: 1 addition & 1 deletion R/roboto-condensed.r
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' A precise & pristine [ggplot2] theme with opinionated defaults and an emphasis on typoghraphy
#' A precise & pristine [ggplot2][ggplot2][ggplot2::ggplot2] theme with opinionated defaults and an emphasis on typoghraphy
#'
#' You should [import_roboto_condensed()] first and also install the fonts on your
#' system before trying to use this theme.
Expand Down
2 changes: 1 addition & 1 deletion R/scales.r
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ is.formula <- function (x) { inherits(x, "formula") }
#' each major break)
#' - A numeric vector of positions
#' - A function that given the limits returns a vector of minor breaks.
#' @param guide guide A function used to create a guide or its name. See [guides()] for more information.
#' @param guide guide A function used to create a guide or its name. See [ggplot2::guides()] for more information.
#' @param n.breaks An integer guiding the number of major breaks. The algorithm may choose a
#' slightly different number to ensure nice break labels. Will only have an effect if
#' `breaks = waiver()`. Use NULL to use the default number of breaks given by the transformation.
Expand Down
2 changes: 1 addition & 1 deletion R/theme-ipsum.r
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' A precise & pristine [ggplot2] theme with opinionated defaults and an emphasis on typography
#' A precise & pristine [ggplot2][ggplot2::ggplot2] theme with opinionated defaults and an emphasis on typography
#'
#' Also has a "dark" / "modern" version for the new RStudio theme
#'
Expand Down
49 changes: 1 addition & 48 deletions man/bit12.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading