Artidata’s Personal Data Visualization Package
Install the development version from GitHub with:
# install.packages("devtools")
devtools::install_github("artidata/artidata.viz")
Setting up a random dataset:
library(artidata.viz)
library(data.table)
library(ggplot2)
library(scales)
set.seed(240193)
N=10000
dtA=data.table(x=runif(N,-3,3),y=runif(N,-3,3),z="A")
dtB=data.table(x=rnorm(N),y=rnorm(N),z="B")
dtC=data.table(x=seq(-3,3,length.out = N))
dtC[,":="(y=0.5*x+rnorm(N,sd=0.5),z="C"),]
dtD=data.table(x=c(rnorm(N/2,-1,.75),rnorm(N/2,1,.75)),
y=c(rnorm(N/2,1,.75),rnorm(N/2,-1,.75)),
z="D")
dt1=rbindlist(list(dtA,dtB,dtC,dtD))
The default scatter plot:
ggplot(dt1,aes(x,y))+
geom_point(size=0.1)+
facet_wrap(vars(z))
The default ggplot2 2D-histogram:
ggplot(dt1,aes(x,y))+
geom_bin2d()+
facet_wrap(vars(z))
2D-Histogram output:
hist2d(dt1,facet=1)
You can also add Linear Regression line:
hist2d(dt1,facet=1,hasLine=T)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.