Skip to contents

Draw line chart

Usage

draw_line(
  data,
  x_var,
  y_var,
  group_var,
  x_axis = NULL,
  y_axis = NULL,
  x_label = NULL,
  y_label = NULL,
  axis_label = c("Age (years)", "Age specific rate"),
  cols = c("darkgreen", "darkred", "gray"),
  line_type = "l",
  main = NULL,
  add = FALSE,
  offset = 0.02,
  ...
)

draw_linechart(x, facet_var, grid, ...)

Arguments

data

The input data frame.

x_var

The variable for the x-axis.

y_var

The variable for the y-axis.

group_var

The variable used to group the data for multiple lines.

x_axis

Optional, the custom X-axis tick values. If not provided, the function generates them.

y_axis

Optional, the custom Y-axis tick values. If not provided, the function generates them.

x_label

Optional, label for X-axis ticks.

y_label

Optional, label for Y-axis ticks.

axis_label

Labels for the axis title, it should be character vector length 2.

cols

Optional. The colors for the lines. If not provided, the function uses default colors.

line_type

1-character string giving the type of plot desired. The following values are possible, for details, see plot: "p" for points, "l" for lines, "b" for both points and lines, "c" for empty points joined by lines, "o" for overplotted points and lines, "s" and "S" for stair steps and "h" for histogram-like vertical lines. Finally, "n" does not produce any points or lines.

main

Optional. The title of the plot.

add

Plots to be added.

offset

Offset of the axis.

...

Parameters

x

The input data frame.

facet_var

Facet var

grid

Grid

Value

Line chart.