ggplot2 demo

title <- rep("A Really Rather Long Text Label", 25)
value <- runif(25, 1,10)
spacing <- seq(1:25)
df <- data.frame(title, value, spacing, stringsAsFactors = FALSE)

myplot <- ggplot(data=df, aes(x=spacing, y=value, label = title)) +
    geom_text(aes(colour = value),
        size = 2.5, fontface = "bold",
        vjust = 0,
        position = position_jitter(width=5, height=0)) +
    theme_bw() +
    scale_x_continuous(limits = c(-5, 30))+
    scale_colour_gradient(low = "#6BAED6", high = "#08306B") +
    opts(axis.title.x = theme_blank(),
        axis.ticks = theme_blank(),
        axis.text.x = theme_blank(),
        legend.position = "none")
myplot

ggplot2 demo

================================

library("ggplot2")
tmp <- data.frame(x=-5:5, y=rnorm(11), lab=LETTERS[1:11])
p <- ggplot(aes(x=x, y=y, label=lab), data=tmp)+
geom_point()+
geom_text(data=subset(tmp, x >0), hjust=-0.5)+
geom_text(data=subset(tmp, x <=0), hjust=1.5)
print(p)
================================
dat <- read.table(text="
cars trucks suvs
1 2 4
3 5 4
6 4 6
4 5 6
9 12 16", header=TRUE,as.is=TRUE)
dat$day <- factor(c("Mo","Tu","We","Th","Fr"),
levels=c("Mo","Tu","We","Th","Fr")) library(reshape2)
library(ggplot2) mdat <- melt(dat, id.vars="day")
head(mdat)
ggplot(mdat, aes(variable, value, fill=day))+
geom_bar(stat="identity", position="dodge")
================================

http://sape.inf.usi.ch/quick-reference/ggplot2/colour
================================ http://docs.ggplot2.org/current/
上一篇:PHP 执行系统外部命令 system() exec() passthru()


下一篇:AOP (Aspect-OrientedProgramming)面向切面编程