首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >geom点和geom段的颜色问题

geom点和geom段的颜色问题
EN

Stack Overflow用户
提问于 2015-02-01 15:58:20
回答 1查看 430关注 0票数 0

我试图从下面的R数据框架制作一个简单的图。我在下面复制了dataframe的dput输出:

代码语言:javascript
复制
structure(list(troponin.cat = c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 
10, 11, 12, 13, 14, 15), percentage = c(0, 13, 29, 40, 47, 53, 
57, 60, 62, 65, 66, 67, 69, 70, 71, 78)), .Names = c("troponin.cat", 
"percentage"), row.names = c("0", "1", "2", "3", "4", "5", "6", 
"7", "8", "9", "10", "11", "12", "13", "14", "15+"), class = "data.frame")

我的情节代码是

代码语言:javascript
复制
plot.2 <- ggplot(data=cumsum, aes(x=troponin.cat, y=percentage))+
geom_point(colour="red", size=5)+
geom_segment(aes(yend = 0, xend = troponin.cat, colour="red", size=5))+
scale_x_continuous(breaks=seq(1, 15, 1))+
geom_line(colour="red")+
theme_classic()

由于某些原因,geom点的颜色与geom段不同,我不知道为什么??

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-02-01 16:17:08

这就是你想要达到的目标吗?

代码语言:javascript
复制
library(ggplot2)

dat <- structure(list(troponin.cat = c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 
10, 11, 12, 13, 14, 15), percentage = c(0, 13, 29, 40, 47, 53, 
57, 60, 62, 65, 66, 67, 69, 70, 71, 78)), .Names = c("troponin.cat", 
"percentage"), row.names = c("0", "1", "2", "3", "4", "5", "6", 
"7", "8", "9", "10", "11", "12", "13", "14", "15+"), class = "data.frame")

plot.2 <- ggplot(data=dat, aes(x=troponin.cat, y=percentage))+
  geom_segment(yend=0, aes(xend=troponin.cat), colour="#a50f15", size=5) +
  geom_point(colour="#a50f15", size=5) +
  geom_line(colour="#a50f15") +
  scale_x_continuous(breaks=seq(1, 15, 1)) +
  theme_classic()

plot.2

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28264646

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档