General purpose convenience visualization function. Simply add other ggplot components after calling this function to customize more (e.g. with facet_wrap or theme calls). Make sure to specify lines = TRUE and/or points = TRUE to add the lines/points respectively. Accepts multiple y variables in which case they are plotted in a facet_wrap with new variables panel holding the name of the y variable panels, y_value holding the values and y_error holding the error values (if y_error is supplied). Also always generates a new column called variable that holds the variable names (y) supplied to this function. All aesthetics parameters expect variables or expressions that are valid in the context of the dt. For convenience, all aesthetics can also be (re)-named on the fly with c(new_name = expr) and will include column units in the legend captions by default.

iso_plot_data(
  dt,
  x,
  y,
  ...,
  y_error = NULL,
  group = NULL,
  color = NULL,
  fill = NULL,
  shape = NULL,
  size = 4,
  linetype = NULL,
  alpha = NULL,
  label = NULL,
  panel = panel ~ .,
  panel_scales = "free_y",
  lines = FALSE,
  points = FALSE,
  date_breaks = NULL,
  date_labels = "%d %b %H:%M"
)

Arguments

dt

data frame to plot data from

x

the column or expression for the x-axis aesthetic. Can be a numeric, text or datetime column (text and datetime column labels will be automatically rotated by 90 degrees). For clarity of the plot, only one x variable or expression is allowed. Use named vector with c(new_x = x) to rename the x variable or expression on the fly. By default will show units in the axis names if there are any. If a datetime column is provided for x, parameters date_breaks (example: date_breaks = "2 hours") and date_labels can be set to fine-tune the x-axis appearance. See scale_date for additional details. Note that x can also be x = NULL for single data point plots - in this case the x axis is completely omitted.

y

which columns/expressions to visualize. Combine with c(y1, y2) or use select syntax (e.g. starts_with(...)) to show multiple variables in a facet_wrap. Use named vector with c(new_y1 = y1) to rename variables/expressions on the fly. By default will show units in the axis names if there are any.

...

additional ggplot objects (e.g. geom_smooth()) that should be added to the plot PRIOR to the automatically generated layers for error bars, points and lines. Notet that to add geoms on top, please use regular iso_plot_data() + geom_smooth() + ... syntax instead.

y_error

an error column for drawing y error bars - if multiple y are provided, error needs to point to the same number of columns

group

what to group by, multiple columns allowed (combine with paste(...)), usually not necessary if groupings are fully defined through other aesthetics

color

variable to use for color aesthetic for the plot or constant value for the point and line color

fill

variable to use for the fill aesthetic of the plot or constant value for the point fill

shape

variable to use for shape aesthetic for the plot or constant vlaue for the point shape

size

variable to use for size aesthetic for the plot or constant value for the points size

linetype

variable to use for linetype aesthetic for the plot or constant value for the line type

alpha

variable to use for the opacity aesthetic for the plot or constant value for the point and line opacity (1 = 100% opaque, 0 = completely transparent)

label

this is primarily of use for turning the generated ggplots into interactive plots via ggplotly as the label will be rendered as an additional mousover label.

panel

whether to panel the data by anything. If using a single parameter (e.g. panel = panel), will generate a facet_wrap. If using a formula (e.g. panel = panel ~ . or panel = file_id ~ panel), will generate a facet_grid. The default for this parameter is to panel via facet grid by the y variable name but only if multiple y columns are provided. Otherwise will not generate any facets. If additional facet parameters are desired, please leave use facet_wrap and facet_grid diretly.

panel_scales

the scales parameter for the facets (if any are used)

lines

whether to plot lines (FALSE by default)

points

whether to plot points (FALSE by default)

date_breaks

what breaks to use for the x axis if it is a datetime

date_labels

datetime label pattern for x axis if it is a datetime

See also