TwoDen
Filed in: R
A function to plot the joint
density of two vectors on a grid. Basically it plots 2-D
histograms.
A function to plot the joint density
of two vectors on a grid. Basically it plots 2-D histograms.
Documentation
twoden(vec1,vec2,breaks="auto",space=1,L=0,xl="",yl="",mn="",hpoint=F,hcol="white")
#vec1 and vec2 are two vectors
# space is the fold increase in breaks for histograms.
# e.g. if you want twice has many breaks as R will pick, space=2
#xl, yl, and mn are titles for the x axis, y axis, and main
# breaks are automatically calculated by default, but user-specified breaks can be added
# hpoint=T adds a circle of color hcol in the box with highest density
# leg=T adds a legend to the right of the plot
Example
twoden(rnorm(1000),rbeta(1000,5,1), L=0.1,space=1,highpoint=T,xl="x~N(0,1)", yl=expression(paste("y~",beta,"(5,1)")));

Code
twoden.txt
Documentation
twoden(vec1,vec2,breaks="auto",space=1,L=0,xl="",yl="",mn="",hpoint=F,hcol="white")
#vec1 and vec2 are two vectors
# space is the fold increase in breaks for histograms.
# e.g. if you want twice has many breaks as R will pick, space=2
#xl, yl, and mn are titles for the x axis, y axis, and main
# breaks are automatically calculated by default, but user-specified breaks can be added
# hpoint=T adds a circle of color hcol in the box with highest density
# leg=T adds a legend to the right of the plot
Example
twoden(rnorm(1000),rbeta(1000,5,1), L=0.1,space=1,highpoint=T,xl="x~N(0,1)", yl=expression(paste("y~",beta,"(5,1)")));

Code
twoden.txt