ggplot2 demo
2024-09-27 03:31:41
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
================================
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/
最新文章
- python统计列表内元素个数
- js表单元素checked、radio被选中的几种方式-遁地龙卷风
- FAST特征点检测
- 第三个Sprint冲刺第三天
- git delete repository
- 【读书笔记】iOS-使用应用内支付注意事项
- Update From 用法
- windows phone 网易云阅读hubtile效果实现
- Spring Cloud介绍 Spring Cloud与Dubbo对比
- UVA507-- Jill Rides Again
- 50 tips of JavaScript
- kubernetes进阶(03)kubernetes的namespace
- Netty与网络编程
- python拟合数据,并通过拟合的曲线去预测新值的方法
- C# string.join
- 从零搭建 ES 搜索服务(五)搜索结果高亮
- [转]Python shutil 模块
- 12C -- ORA-28040
- 2-MAVEN 基本命令
- 问题1:jquery实现全选功能,第二次失效(已解决)
热门文章
- ios应用启动后的自动版本检测方式
- extern ";C";——用“C”来规约在C++中用C的方式进行编译和链接
- win7 telnet命令无法使用
- ETL Pentaho Data Integration (Kettle) 插入/更新 问题 etl
- python 发邮件 utf-8
- POJ 3614 Sunscreen 贪心
- 【转载】VMWare ESXi 5.0和vSphere Client安装和配置
- 【BZOJ】【2594】【WC2006】水管局长数据加强版
- Guava文档翻译之 Guava简介
- POJ1182 食物链