Skip to contents

Draw an interactive scatterplot or line plot using 'C3.js'.

Usage

# S3 method for default
c3plot(
  x,
  y,
  type = "p",
  xlim = NULL,
  ylim = NULL,
  main = NULL,
  xlab = NULL,
  ylab = NULL,
  zoom = TRUE,
  col.group = NULL,
  col = NULL,
  legend.title = NULL,
  legend.position = "right",
  sci.x = FALSE,
  sci.y = FALSE,
  ...
)

Arguments

x

the x coordinates for the plot.

y

the y coordinates for the plot.

type

1-character string giving the type of plot desired. The following values are possible: "p" for points, "l" for lines, and "b" for both points and lines.

xlim

the x limits (x1, x2) of the plot.

ylim

the y limits of the plot.

main

a main title for the plot.

xlab

a label for the x axis, defaults to a description of x.

ylab

a label for the y axis, defaults to a description of y.

zoom

logical; should the zooming feature (controlled by mouse wheel event) be enabled for the plot?

col.group

optionally, a factor the same length as x by which to group and color points.

col

The colors for the lines and points. If col.group is specified, this can be a vector of colors to use for each group in the data. If NULL, the C3 default colors are used.

legend.title

a title for the legend. Defaults to a description of a description of col.group if not set. You can also use legend.title = FALSE to suppress to not show a title for the legend.

legend.position

Position of the plot legend. Possible values are "right", "inset", and "hide". This is ignored if all points are colored the same (i.e. no value was set for col.group); no legend will be shown in those instances.

sci.x

logical indicating whether scientific notation should be used for the x-axis.

sci.y

logical indicating whether scientific notation should be used for the x-axis.

...

arguments passed to htmlwidgets::createWidget(): width, height, and elementId. These arguments default to NULL.

Examples

data(mtcars)
c3plot(mtcars$hp, mtcars$qsec)
c3plot(mtcars$disp, mtcars$hp, main = "Displacement vs. HP in mtcars")