Learn R Programming

chronicle (version 0.1.0)

make_lineplot: Create a line plot from a data frame through ggplotly

Description

Create a line plot from a data frame through ggplotly

Usage

make_lineplot(
  dt,
  x,
  y,
  groups = NULL,
  faceted = TRUE,
  scales = "fixed",
  smooth_trend = FALSE,
  ggtheme = "minimal",
  x_axis_label = NULL,
  y_axis_label = NULL,
  plot_palette = NULL,
  plot_palette_generator = "plasma"
)

Arguments

dt

data.frame containing the data to plot.

x

Value on the x axis.

y

Value on the y axis.

groups

Name of the column containing the different groups.

faceted

If TRUE (default), each group will be plotted separately.

scales

From ggplot2::facet_wrap: Should scales be 'fixed', 'free', or free in one dimension ('free_x', 'free_y'). Default is 'fixed'.

smooth_trend

If TRUE, adds a ggplot2::geom_smooth() line to the plot.

ggtheme

ggplot2 theme function to apply. Default is ggplot2::theme_minimal.

x_axis_label

Label for the x axis.

y_axis_label

Label for the y axis.

plot_palette

Character vector of hex codes specifying the colors to use on the plot.

plot_palette_generator

Palette from the viridis package, used in case plot_palette is unspecified or insufficient for the number of colors required.

Value

A plotly-ized version of a grouped ggplot line plot.

Examples

Run this code
# NOT RUN {
make_lineplot(dt = ggplot2::mpg,
              x = 'hwy',
              y = 'cty',
              groups = 'manufacturer',
              faceted = FALSE)

make_lineplot(dt = ggplot2::mpg,
              x = 'hwy',
              y = 'cty',
              groups = 'manufacturer',
              faceted = TRUE,
              scales = 'free')

# }

Run the code above in your browser using DataLab