Title: | Colormeter Guide Extension |
---|---|
Description: | A 'ggplot2' guide extension for fill and color scales in the style of a dashboard meter. The dashboard legend maps onto continuous aesthetics and can be customized for its dimensions and the style of its various components including the labels and frames. Fine-grained control over the positioning of dashboard components is possible via an option to expose the legend-internal coordinate system. |
Authors: | June Choe [aut, cre, cph] |
Maintainer: | June Choe <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.0 |
Built: | 2024-12-19 04:52:31 UTC |
Source: | https://github.com/yjunechoe/ggcolormeter |
A color legend in the style of a dashboard meter
guide_colormeter( title = ggplot2::waiver(), title.theme = NULL, label.theme = NULL, legend_size = unit(5, "lines"), legend_padding = unit(c(1.2, 1, 0.3, 1), "lines"), title_position = c(0, 0), arc_range = c(-4/7 * pi, 4/7 * pi), arc_radius = 1, arc_width = arc_radius/4, arc_gap = arc_radius/5, arc_rounding = 0, label_radius = arc_radius * 1.25, dashboard_radius = label_radius * 1.2, dashboard_color = "black", dashboard_fill = NA, dashboard_linewidth = 0.5, dashboard_linetype = 1, clip_dashboard = TRUE, close_dashboard = clip_dashboard, frame_color = NA, frame_linewidth = 0.5, frame_linetype = 1, aspect.ratio = 1, show.limits = NULL, debug = FALSE, reverse = FALSE, available_aes = c("colour", "color", "fill"), ... )
guide_colormeter( title = ggplot2::waiver(), title.theme = NULL, label.theme = NULL, legend_size = unit(5, "lines"), legend_padding = unit(c(1.2, 1, 0.3, 1), "lines"), title_position = c(0, 0), arc_range = c(-4/7 * pi, 4/7 * pi), arc_radius = 1, arc_width = arc_radius/4, arc_gap = arc_radius/5, arc_rounding = 0, label_radius = arc_radius * 1.25, dashboard_radius = label_radius * 1.2, dashboard_color = "black", dashboard_fill = NA, dashboard_linewidth = 0.5, dashboard_linetype = 1, clip_dashboard = TRUE, close_dashboard = clip_dashboard, frame_color = NA, frame_linewidth = 0.5, frame_linetype = 1, aspect.ratio = 1, show.limits = NULL, debug = FALSE, reverse = FALSE, available_aes = c("colour", "color", "fill"), ... )
title |
A character string or expression indicating a title of guide.
If |
title.theme |
A theme object for rendering the title text. Usually the
object of |
label.theme |
A theme object for rendering the label text. Usually the
object of |
legend_size |
Size of the legend box. |
legend_padding |
Spacing between the color meter and the legend boundary. |
title_position |
< |
arc_range |
< |
arc_radius |
< |
arc_width |
< |
arc_gap |
< |
arc_rounding |
< |
label_radius |
< |
dashboard_radius |
< |
dashboard_color |
Dashboard background color. |
dashboard_fill |
Dashboard background fill. |
dashboard_linewidth |
Dashboard background line width. |
dashboard_linetype |
Dashboard background line type. |
clip_dashboard |
Whether the dashboard circle should clip to the legend boundary. |
close_dashboard |
Whether the dashboard should be closed where it meets the legend boundary. |
frame_color |
Color of the frame drawn around the arcs. |
frame_linewidth |
Width of the frame drawn around the arcs. |
frame_linetype |
Line type of the frame drawn around the arcs. |
aspect.ratio |
Aspect ratio for the legend. |
show.limits |
Logical. Should the limits of the scale be shown with
labels and ticks. Default is |
debug |
If |
reverse |
logical. If |
available_aes |
A vector of character strings listing the aesthetics for which a colourbar can be drawn. |
... |
Ignored. |
A guide object of class 'colormeter'
library(ggplot2) # A standard plot p <- ggplot(mtcars, aes(drat, hp)) + geom_point(aes(color = mpg)) # Colormeter guide for color scale p + scale_color_viridis_c( option = "inferno", breaks = scales::breaks_pretty(10), guide = guide_colormeter() )
library(ggplot2) # A standard plot p <- ggplot(mtcars, aes(drat, hp)) + geom_point(aes(color = mpg)) # Colormeter guide for color scale p + scale_color_viridis_c( option = "inferno", breaks = scales::breaks_pretty(10), guide = guide_colormeter() )