The blog is a collection of script examples with example data and output plots. R produce excellent quality graphs for data analysis, science and business presentation, publications and other purposes. Self-help codes and examples are provided. Enjoy nice graphs !!

Labels
2d
(1)
3 vartiable plots
(5)
3D plots
(8)
arch
(1)
area
(1)
association plot
(4)
bar
(1)
barchart
(13)
bean plot
(1)
beeswarm
(1)
binormial
(1)
biplot
(1)
box-percentile
(2)
box-whisker plot
(1)
boxplot
(10)
bubble plot
(5)
calendar
(1)
categorical data
(6)
centepede plot
(1)
circle
(2)
circular
(1)
cluster
(4)
color
(2)
colour
(1)
combination plot
(10)
countur
(1)
cross bar
(1)
cumulative
(1)
curve
(3)
dendogram
(3)
density
(13)
diagram
(2)
distribution
(9)
ditribution
(1)
dot plot
(1)
double axis
(1)
ellipse
(2)
error bar
(6)
factor plot
(3)
fluctutation diagram
(1)
google
(1)
grid plot
(1)
heatmap
(20)
hexabin plot
(1)
histogram
(11)
hive
(1)
kernel density
(4)
ladder plot
(2)
large data points
(4)
level plot
(1)
line plot
(3)
line range
(1)
manhattan plot
(1)
map
(13)
mosaic plot
(1)
normal
(2)
notched
(1)
parallel plot
(1)
pedigree plot
(1)
phylogentic tree
(1)
piechart
(3)
points
(2)
polar
(1)
Q-Q plot
(1)
raster
(2)
regression line
(3)
ribbon plot
(1)
rootogram
(1)
rugs
(2)
scale plot
(1)
scenes
(1)
shaded
(1)
spatial plot
(2)
sphere
(1)
spike histogram
(1)
Spine plot
(1)
stacked bar
(1)
Sunflower
(1)
ternary plot
(1)
text only
(1)
timeseries
(6)
trellis plot
(8)
two axis
(1)
vinn diagram
(1)
voilin plot
(2)
wireframe plot
(1)
xy barplot
(4)
xy line
(10)
xy points
(25)
Showing posts with label kernel density. Show all posts
Showing posts with label kernel density. Show all posts
Monday, April 8, 2013
RG#35: density or Kernel density plot
Sunday, April 7, 2013
RG#21: Plotting curves (any formula, normal density )
#Example:
curve(x^2, col = "red")
curve(x^2, col = "red")
curve(x^3-x+1.5,from=-10,to=10,lty=2, col = "blue")
# normal curve
x=seq(-50,150,length=1000)
set.seed(1234)
y=dnorm(x,mean=50,sd=30)
plot(x,y,type="l",lwd=2,col="red")
y=dnorm(x,mean=50,sd=30)
plot(x,y,type="l",lwd=2,col="red")
# add one or more curves
curve(x^2-1, col = "green2")
curve(x^2-5*x, -2.5, 2.5, add = TRUE, col = "red")
# add curves to scatter plot
# xyscatter plot
set.seed(1234)
x = c(0.1, 0.2, 0.3, 0.4, 0.5)
y = (-0.5*log (1-(2*x)) + rnorm(length (x), 0.2, 0.1))
plot(x,y, col = "red", pch = 18)
curve(-0.5*log (1-(2*x)),from=0,to=0.5, lty=2, col = "blue", add = TRUE)
Friday, April 5, 2013
RG#11:multiple histograms with normal distribution or density curve overlayed
#data
set.seed(1233)
data1 < - data.frame(pop =c(rep("A x B", 200), rep("A x C", 200), rep("B x C", 200) ) , var1 = c(rnorm(1000, 90,10), rnorm(1000, 50, 10), rnorm(1000, 20, 30)))
#plot
require(lattice)
# plot overall distribution
histogram(~ var1, data= data1, nint = 12, xlab = "trait1(measuring unit)", type = "density", panel = function(x, ...) {
panel.histogram(x, ...)
panel.mathdensity(dmath = dnorm, col = "black",
args = list(mean=mean(x),sd=sd(x)))
} )
# plot by each group
histogram(~ var1|factor(pop), data= data1, nint = 10, xlab = "trait1(measuring unit)", type = "density",
panel = function(x, ...) {
panel.histogram(x, col = "darkgreen", ...)
panel.mathdensity(dmath = dnorm, col = "red",
args = list(mean=mean(x),sd=sd(x)))
} )
set.seed(1233)
data1 < - data.frame(pop =c(rep("A x B", 200), rep("A x C", 200), rep("B x C", 200) ) , var1 = c(rnorm(1000, 90,10), rnorm(1000, 50, 10), rnorm(1000, 20, 30)))
#plot
require(lattice)
# plot overall distribution
histogram(~ var1, data= data1, nint = 12, xlab = "trait1(measuring unit)", type = "density", panel = function(x, ...) {
panel.histogram(x, ...)
panel.mathdensity(dmath = dnorm, col = "black",
args = list(mean=mean(x),sd=sd(x)))
} )
# plot by each group
histogram(~ var1|factor(pop), data= data1, nint = 10, xlab = "trait1(measuring unit)", type = "density",
panel = function(x, ...) {
panel.histogram(x, col = "darkgreen", ...)
panel.mathdensity(dmath = dnorm, col = "red",
args = list(mean=mean(x),sd=sd(x)))
} )
Labels:
density,
ditribution,
histogram,
kernel density
RG#9: Drawing basic normal curve
Subscribe to:
Posts (Atom)