Skip to contents

Create Jittered Points Scatter Chart

Usage

v_jitter(
  vc,
  mapping = NULL,
  data = NULL,
  name = NULL,
  width = NULL,
  height = NULL,
  ...,
  serie_id = NULL,
  data_id = NULL
)

Arguments

vc

A chart initialized with vchart().

mapping

Default list of aesthetic mappings to use for chart.

data

Default dataset to use for chart. If not already a data.frame, it will be coerced to with as.data.frame.

name

Name for the serie, only used for single serie (no color/fill aesthetic supplied).

width, height

Amount of vertical and horizontal jitter. The jitter is added in both positive and negative directions, so the total spread is twice the value specified here.

If omitted, defaults to 40% of the resolution of the data: this means the jitter values will occupy 80% of the implied bins. Categorical data is aligned on the integers, so a width or height of 0.5 will spread the data so it's not possible to see the distinction between the categories.

...

Additional parameters for the serie.

data_id, serie_id

ID for the data/serie, can be used to further customize the chart with v_specs().

Value

A vchart() htmlwidget object.

Examples


library(vchartr)

data("mpg", package = "ggplot2")
data("penguins", package = "palmerpenguins")

# With continuous x
vchart(mpg) %>% 
  v_jitter(aes(cyl, hwy))
# with discrete x vchart(penguins) %>% v_jitter(aes(species, bill_length_mm))
# Colour points vchart(mpg) %>% v_jitter(aes(cyl, hwy, colour = class))
# Use smaller width/height to emphasise categories vchart(mpg) %>% v_jitter(aes(cyl, hwy), width = 0.25)
# Use larger width/height to completely smooth away discreteness vchart(mpg) %>% v_jitter(aes(cty, hwy), width = 0.5, height = 0.5)