Function wraps ggplot2::geom_pointrange
to produce x/y plot of numeric ranges.
Function returns a ggplot2 plot object displaying the individual
spread or vertical interval/range for a collection of x/y pairs of points.
create_range_plot(
df = NULL,
orientation = "x",
aes_x = NULL,
aes_y = NULL,
aes_min = NULL,
aes_max = NULL,
title = NULL,
subtitle = NULL,
caption = NULL,
center_titles = FALSE,
x_title = NULL,
y_title = NULL,
hide_x_tics = FALSE,
hide_y_tics = FALSE,
rot_x_tic_angle = 0,
rot_y_tic_label = FALSE,
x_limits = NULL,
x_major_breaks = waiver(),
x_minor_breaks = waiver(),
x_labels = waiver(),
x_log10 = FALSE,
y_limits = NULL,
y_major_breaks = waiver(),
y_minor_breaks = waiver(),
y_labels = waiver(),
y_log10 = FALSE,
axis_text_size = 11,
pts_fill = "white",
pts_shape = 21,
pts_stroke = 1,
pts_size = 2,
line_type = "solid",
line_width = 1,
line_pts_color = "black",
line_pts_alpha = 1,
panel_color = "white",
panel_border_color = "black",
show_major_grids = TRUE,
show_minor_grids = TRUE,
bold_x = NULL,
bold_x_color = "black",
bold_x_linetype = "dashed",
bold_y = NULL,
bold_y_color = "black",
bold_y_linetype = "dashed",
silent_NA_warning = FALSE,
png_file_path = NULL,
png_width_height = c(480, 480)
)
A ggplot class object.
The target data frame from which the point ranges are plotted.
A string that sets the axis on which the range should run along. Acceptable values are either "x" (the default) or "y".
Sets the x axis numeric variable name from 'df'.
Sets a y axis variable name from 'df'.
A string that sets a numeric variable from 'df' that defines the minimum values for the range.
A string that sets a numeric variable from 'df' that defines the maximum values for the range.
A string that sets the plot title.
A string that sets the plot subtitle.
A string that sets the plot caption
A logical which if TRUE
centers both the 'title'
and 'subtitle'.
A string that sets the x axis title. If NULL
(the default) then the x axis title does not appear.
A string that sets the y axis title. If NULL
(the default) then the y axis title does not appear.
A logical that controls the appearance of the x axis tics.
A logical that controls the appearance of the y axis tics.
A numeric that sets the angle of rotation for the x tic labels. When x tic labels are long, a value of 40 for this argument usually works well.
A logical which if TRUE rotates the y tic labels 90 degrees for enhanced readability.
A numeric 2 element vector that sets the minimum and maximum for the x axis.
Use NA
to refer to the existing minimum and maximum.
A numeric vector or function that defines the exact major tic locations along the x axis.
A numeric vector or function that defines the exact minor tic locations along the x axis.
A character vector with the same length as 'x_major_breaks', that labels the major tics.
A logical which if TRUE
will use a log10 scale for the x axis.
A numeric 2 element vector that sets the minimum and maximum for the y axis.
Use NA
to refer to the existing minimum and maximum.
A numeric vector or function that defines the exact major tic locations along the y axis.
A numeric vector or function that defines the exact minor tic locations along the y axis.
A character vector with the same length as 'y_major_breaks', that labels the major tics.
A logical which if TRUE
will use a log10 scale for the y axis.
A numeric that sets the font size along the axis'. Default is 11.
A string that sets the fill color of the points.
A numeric integer that sets the shape of the points. Typical values are 21 "circle", 22 "square", 23 "diamond", 24 "up triangle", 25 "down triangle".
A numeric that sets the drawing width for a point shape.
A numeric that sets the point size.
A string that sets range line type "twodash", "solid", "longdash", "dotted", "dotdash", "dashed", "blank".
A numeric that sets the width of the lines.
A string that sets the color of the range lines and outlines of the points.
A numeric value that sets the alpha level of points.
A string in hexidecimal or color name that sets the plot panel's color. The default is "white".
A string in hexidecimal or color name that sets the plot panel's border color. The default is "black".
A logical that controls the appearance of major grids.
A logical that controls the appearance of minor grids.
A numeric that sets the x-intercept for plotting a bold vertical line.
A string that sets the color of 'bold_x'.
A string that set the linetype of 'bold_x'.
A numeric that sets the y-intercept for plotting a bold horizontal line.
A string that sets the color of 'bold_y'.
A string that set the linetype of 'bold_y'.
A logical that controls the appearance of a console warning when Na's are removed.
A character string with the directory and file name to produce a png image of the plot.
A numeric vector that sets the width and height of the png image in pixels. The default is c(480,480). There are 37.8 pixels in a centimeter.
library(ggplot2)
library(RplotterPkg)
RplotterPkg::create_range_plot(
df = RplotterPkg::penguins_stats,
orientation = "x",
aes_x = "avg_body_mass",
aes_y = "species",,
aes_min = "min_body_mass",
aes_max = "max_body_mass",
title = "Average and Range of Penguins Body Mass(g) by Species",
subtitle = "Source: palmerpenguins",
center_titles = TRUE,
x_title = "Body Mass(g)",
y_title = "Species",
pts_fill = "blue",
pts_shape = 22,
pts_stroke = 1.7,
line_width = 1.5,
line_type = "solid",
line_pts_color = "red",
line_pts_alpha = 0.5,
x_limits = c(2500, 7000),
x_major_breaks = seq(2500,7000,500),
show_major_grids = TRUE,
show_minor_grids = FALSE
)
Run the code above in your browser using DataLab