Title: | What the Package Does (One Line, Title Case) |
---|---|
Description: | What the package does (one paragraph). |
Authors: | First Last [aut, cre] (YOUR-ORCID-ID) |
Maintainer: | First Last <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.0.9000 |
Built: | 2024-10-30 04:45:57 UTC |
Source: | https://github.com/selkamand/utilitybeltgg |
Add text labels indicating counts above barplot columns. Works on plots that have a geom_bar() layer. Works even if you flip axis with coord_flip().
geom_barplot_counts( distance_from_bar = 1.5, orientation = "h", size = 4, fontface = "bold", alpha = 0.8, color = "black", family = "Helvetica" )
geom_barplot_counts( distance_from_bar = 1.5, orientation = "h", size = 4, fontface = "bold", alpha = 0.8, color = "black", family = "Helvetica" )
distance_from_bar |
distance between text and cbar |
orientation |
orientation of barplot ("h" / "horizontal" / "v" / "vertical") |
size |
size of text (number) |
fontface |
Font face ("plain", "italic", "bold", "bold.italic") (string) |
alpha |
transparancy (number) |
color |
colour (string) |
family |
font family (string) |
ggplot geom
mtcars %>% ggplot2::ggplot(ggplot2::aes(x=as.character(cyl))) + ggplot2::geom_bar() + ggplot2::xlab("cylinders") + geom_barplot_counts()
mtcars %>% ggplot2::ggplot(ggplot2::aes(x=as.character(cyl))) + ggplot2::geom_bar() + ggplot2::xlab("cylinders") + geom_barplot_counts()
Adds a crossbar to a ggplot. Best used when comparing one categorical and one numeric variable using geom_point / geom_jitter(height=0).
geom_crossbar_predefined( summaryfunction = stats::median, width = 0.4, size = 0.3, colour )
geom_crossbar_predefined( summaryfunction = stats::median, width = 0.4, size = 0.3, colour )
summaryfunction |
a function run on the y aesthetic to determine where line is drawn. Options include median, mean, max, min, or any other function that summarises a numeric vector into a single number (function) |
width |
width of crossbar |
size , colour
|
ggplot aesthetics |
ggplot geom
mtcars %>% ggplot2::ggplot(ggplot2::aes(cyl>6, mpg)) + ggplot2::geom_point() + geom_crossbar_predefined()
mtcars %>% ggplot2::ggplot(ggplot2::aes(cyl>6, mpg)) + ggplot2::geom_point() + geom_crossbar_predefined()
Plot
ggbarplot( data, col, orientation = "h", fill = NULL, title = NULL, position = "stack", ... )
ggbarplot( data, col, orientation = "h", fill = NULL, title = NULL, position = "stack", ... )
data |
a dataset to plot (dataframe) |
col |
column of dataframe to plot (don't quote) |
orientation |
orientation of barplot ("h" / "horizontal" / "v" / "vertical") |
fill |
column of dataframe to color based on (don't quote) |
title |
title of graph (string) |
position |
see ?ggplot2::geom_bar for details (Usually one of: "stack", "dodge", "fill") |
... |
set any other barplot property. See ?ggplot2::geom_bar for details. (e.g. alpha = 0.4) |
ggplot
ggbarplot(iris, Species, fill = Species, orientation = "horizontal", title = "My Freq Graph")
ggbarplot(iris, Species, fill = Species, orientation = "horizontal", title = "My Freq Graph")
Density Plot
ggdensity( data, col, fill = "steelblue", alpha = 0.5, summary_stats = FALSE, text_xpos = NULL, text_ypos = 0.04, text_sigfigs = Inf, ... )
ggdensity( data, col, fill = "steelblue", alpha = 0.5, summary_stats = FALSE, text_xpos = NULL, text_ypos = 0.04, text_sigfigs = Inf, ... )
data |
datafrmae |
col |
column (don't quote) |
fill |
geom_density fill color |
alpha |
geom_density alpha color |
summary_stats |
add text with summary stats to plot (boolean) |
text_xpos |
x position of summary stat text (numeric) |
text_ypos |
y position of summary stat text (numeric) |
text_sigfigs |
number of significant figures to write summary statistic to (numeric) |
... |
other geom_density aesthetics (e.g. linetype = "dashed") |
gglot
ggdensity(mtcars, mpg, summary = TRUE)
ggdensity(mtcars, mpg, summary = TRUE)
Will replace infinite values by the nearest limit.
scale_show_infinites_x( trans = "identity", limits = NULL, position = "bottom", breaks = ggplot2::waiver(), ... )
scale_show_infinites_x( trans = "identity", limits = NULL, position = "bottom", breaks = ggplot2::waiver(), ... )
trans |
For continuous scales, the name of a transformation object or the object itself. Built-in transformations include "asn", "atanh", "boxcox", "date", "exp", "hms", "identity", "log", "log10", "log1p", "log2", "logit", "modulus", "probability", "probit", "pseudo_log", "reciprocal", "reverse", "sqrt" and "time". A transformation object bundles together a transform, its inverse,
and methods for generating breaks and labels. Transformation objects
are defined in the scales package, and are called |
limits |
One of:
|
position |
For position scales, The position of the axis.
|
breaks |
One of:
|
... |
Other arguments to ggplot2::scale_x_continuous or ggplot2::scale_y_continuous |
This function also allows you to pass arguments along to ggplot2::scale_x_continuous()
since once you add this call you won't be able to edit the continuous scale elsewhere.
Oftentimes you'll want to use the trans
argument to, for example, visualize your data on a log scale.
ScaleContinuousPosition object that can be added to a ggplot object using '+'
## Not run: data = mtcars dplyr::mutate(qsec2 = ifelse(qsec > 19, Inf, qsec)) # Plot with infinites set to nearest limit data %>% ggplot2::ggplot(ggplot2::aes(x=qsec2, y=carb)) + ggplot2::geom_point() + scale_show_infinites_x() # Plot on a log10 scale with infinites set to nearest limit data %>% ggplot2::ggplot(ggplot2::aes(x=qsec2, y=carb)) + ggplot2::geom_point() + scale_show_infinites_x(trans="log10") ## End(Not run)
## Not run: data = mtcars dplyr::mutate(qsec2 = ifelse(qsec > 19, Inf, qsec)) # Plot with infinites set to nearest limit data %>% ggplot2::ggplot(ggplot2::aes(x=qsec2, y=carb)) + ggplot2::geom_point() + scale_show_infinites_x() # Plot on a log10 scale with infinites set to nearest limit data %>% ggplot2::ggplot(ggplot2::aes(x=qsec2, y=carb)) + ggplot2::geom_point() + scale_show_infinites_x(trans="log10") ## End(Not run)
Will replace infinite values by the nearest limit.
scale_show_infinites_y( trans = "identity", limits = NULL, position = "bottom", breaks = ggplot2::waiver(), ... )
scale_show_infinites_y( trans = "identity", limits = NULL, position = "bottom", breaks = ggplot2::waiver(), ... )
trans |
For continuous scales, the name of a transformation object or the object itself. Built-in transformations include "asn", "atanh", "boxcox", "date", "exp", "hms", "identity", "log", "log10", "log1p", "log2", "logit", "modulus", "probability", "probit", "pseudo_log", "reciprocal", "reverse", "sqrt" and "time". A transformation object bundles together a transform, its inverse,
and methods for generating breaks and labels. Transformation objects
are defined in the scales package, and are called |
limits |
One of:
|
position |
For position scales, The position of the axis.
|
breaks |
One of:
|
... |
Arguments passed on to |
ScaleContinuousPosition object that can be added to a ggplot object using '+'
## Not run: data = mtcars %>% dplyr::mutate(qsec2 = ifelse(qsec > 19, Inf, qsec)) # Plot with infinites set to nearest limit data %>% ggplot2::ggplot(ggplot2::aes(x=carb, y=qsec2)) + ggplot2::geom_point() + scale_show_infinites_y() # Plot on a log10 scale with infinites set to nearest limit data %>% ggplot2::ggplot(ggplot2::aes(x=carb, y=qsec2)) + ggplot2::geom_point() + scale_show_infinites_y(trans="log10") ## End(Not run)
## Not run: data = mtcars %>% dplyr::mutate(qsec2 = ifelse(qsec > 19, Inf, qsec)) # Plot with infinites set to nearest limit data %>% ggplot2::ggplot(ggplot2::aes(x=carb, y=qsec2)) + ggplot2::geom_point() + scale_show_infinites_y() # Plot on a log10 scale with infinites set to nearest limit data %>% ggplot2::ggplot(ggplot2::aes(x=carb, y=qsec2)) + ggplot2::geom_point() + scale_show_infinites_y(trans="log10") ## End(Not run)
Custom Themes
theme_axis_titles_cleveland()
theme_axis_titles_cleveland()
ggtheme
ggplot theme that fixes a bunch of issues I tend to have with plots.
theme_common_adjustments( dist_from_plot_xlab = 10, dist_from_plot_ylab = 10, dist_from_plot_ggtitle = 10, no_background = FALSE, subtitle_face = "plain" )
theme_common_adjustments( dist_from_plot_xlab = 10, dist_from_plot_ylab = 10, dist_from_plot_ggtitle = 10, no_background = FALSE, subtitle_face = "plain" )
dist_from_plot_xlab |
distance between x axis title and plot (number) |
dist_from_plot_ylab |
distance between y axis title and plot (number) |
dist_from_plot_ggtitle |
distance between y axis title and plot (number) |
no_background |
set all backgrounds to clear? (flag) |
subtitle_face |
Font face ("plain", "italic", "bold", "bold.italic") |
By default, will bold center axis and plot titles and tweak distane of axis_titles to plot
ggtheme
mtcars %>% ggplot2::ggplot(ggplot2::aes(cyl>6, mpg)) + ggplot2::geom_point() + theme_common_adjustments()
mtcars %>% ggplot2::ggplot(ggplot2::aes(cyl>6, mpg)) + ggplot2::geom_point() + theme_common_adjustments()
Custom Themes
theme_fivethirtyeight_two()
theme_fivethirtyeight_two()
ggtheme
Custom Themes
theme_legend_bottom(direction = "horizontal")
theme_legend_bottom(direction = "horizontal")
direction |
"Vertical or Horizontal" |
ggtheme
Custom Themes
theme_legend_left(direction = "vertical")
theme_legend_left(direction = "vertical")
direction |
"Vertical or Horizontal" |
ggtheme
Custom Themes
theme_legend_right(direction = "vertical")
theme_legend_right(direction = "vertical")
direction |
"Vertical or Horizontal" |
ggtheme
Custom Themes
theme_legend_title_none()
theme_legend_title_none()
ggtheme
Custom Themes
theme_legend_top(direction = "horizontal")
theme_legend_top(direction = "horizontal")
direction |
"Vertical or Horizontal" |
ggtheme
A minimal theme with a border. Works well for faceted graphs
theme_minimal_bordered(border_color = "grey40", border_thickness = NULL, ...)
theme_minimal_bordered(border_color = "grey40", border_thickness = NULL, ...)
border_color |
Colour of border |
border_thickness |
border thickness in mm |
... |
Arguments passed on to
|
mtcars %>% ggplot2::ggplot(ggplot2::aes(x = mpg, y=disp)) + ggplot2::geom_point() + theme_minimal_bordered()
mtcars %>% ggplot2::ggplot(ggplot2::aes(x = mpg, y=disp)) + ggplot2::geom_point() + theme_minimal_bordered()
theme_no_legend(...)
theme_no_legend(...)
... |
no arguments are used. Included only so code written for older versions of package doesn't break |
theme
theme_no_legend_title(...)
theme_no_legend_title(...)
... |
no arguments are used. Included only so code written for older versions of package doesn't break |
theme