Shorcut for create scatter plots

Description

This function helps to create scatter plot from two numerics vectors. Options argumets like size, color and label for points are added.

Usage

1
2
hc_add_series_scatter(hc, x, y, z = NULL, color = NULL, label = NULL,
  showInLegend = FALSE, ...)

Arguments

hc

A highchart htmlwidget object.

x

A numeric vector.

y

A numeric vector. Same length of x.

z

A numeric vector for size. Same length of x.

color

A vector to color the points.

label

A vector to put names in the dots if you enable the datalabels.

showInLegend

Logical value to show or not the data in the legend box.

...

Aditional shared arguments for the data series (http://api.highcharts.com/highcharts#series).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 
hc <- highchart()

hc_add_series_scatter(hc, mtcars$wt, mtcars$mpg)
hc_add_series_scatter(hc, mtcars$wt, mtcars$mpg, mtcars$drat)
hc_add_series_scatter(hc, mtcars$wt, mtcars$mpg, mtcars$drat, mtcars$am)
hc_add_series_scatter(hc, mtcars$wt, mtcars$mpg, mtcars$drat, mtcars$qsec)
hc_add_series_scatter(hc, mtcars$wt, mtcars$mpg, mtcars$drat, mtcars$qsec, rownames(mtcars))

# Add named attributes to data (attributes length needs to match number of rows)
hc_add_series_scatter(hc, mtcars$wt, mtcars$mpg, mtcars$drat, mtcars$qsec,
                      name = rownames(mtcars), gear = mtcars$gear) %>%
  hc_tooltip(pointFormat = "<b>{point.name}</b><br/>Gear: {point.gear}")
  

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.