This package provides a interactive rug plot: it plots the values of a labelled numeric vector.
d3rug
is inspired by the strip plot of Maarten Lambrechts
library(d3rug) income <- state.x77[,2] d3rug(income, height="100px")
The user can see the labels of the values by moving the mouse to the value.
The d3rug
function can be tuned and adapted in the following ways:
col
different colors can be set: if col
is of length 1, all stripes will have the same s=corilliteracy_levels <- cut(state.x77[,3], 5) pal <- colorRampPalette(c("green","gray", "orange"))(nlevels(illiteracy_levels)) col = pal[illiteracy_levels] d3rug(income, col=col)
You can supply your own labels:
d3rug(income, labels=state.abb)
col_hover
the color for hovering a value can be set.d3rug(income, col_hover = "red")
group
you can highlight a group of valuesgroup <- substr(state.abb, 1, 1) d3rug(income, col_hover = "red", group = group)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.