0
bay <- structure(list(wbi = c(0.08, 0.08, 0.02, 0.26, 0.08, 0.08, 0.02, 
0.08, 0.08, 0.03, 0.26, 0.02, 0.08, 0.03, 0.08, 0.03, 0.08, 0.03, 
0.03, 0.02, 0.03, 0.08, 0.08, 0.08, 0.08, 0.08, 0.08, 0.03, 0.08, 
0.08), medprice.n2 = c(39.99, 54.99, 44.99, 59.99, 49.99, 44.99, 
59.99, 54.99, 39.99, 49.99, 49.99, 59.99, 54.99, 44.99, 39.99, 
54.99, 39.99, 49.99, 44.99, 59.99, 39.99, 44.99, 49.99, 54.99, 
44.99, 54.99, 39.99, 39.99, 49.99, 59.99)), .Names = c("wbi", 
"medprice.n2"), row.names = c(2L, 21L, 23L, 46L, 60L, 62L, 63L, 
64L, 66L, 67L, 72L, 74L, 76L, 77L, 78L, 80L, 82L, 83L, 85L, 89L, 
91L, 92L, 95L, 96L, 97L, 102L, 103L, 104L, 106L, 108L), class = "data.frame")

下面的代码生成带有红线的图形。我想把红线改成#5182BA"red"我将下面第六行中的单词替换为hex #5182BA但不起作用(出现红线)。我在这个问题上进行了高低搜索,查阅了我的 ggplot2 书籍,但找不到解决方案。谢谢

gg <- subset(bay, hp_quota == 1)
reg <- with(gg, lm(wbi ~ medprice.n2))
summary(reg)
ddply(gg, .(medprice.n2), summarise, mean=round(mean(wbi(q2final), na.rm=TRUE), 2))
ggplot(gg, aes( x = medprice.n2, 100*(y = wbi(q2final))))  + 
stat_smooth( method = lm, se = FALSE, size = 1.3, colour="red", fill="red")
coord_cartesian(ylim = c(0,25)) +  
scale_y_continuous(breaks= c(0, 5, 10, 15, 20, 25)) + 
theme(panel.grid.minor = element_blank()) +
theme(text=element_text(family="Arial", size=16)) +
theme(axis.ticks = element_blank()) + 
theme(axis.title.x = element_blank()) + 
#theme(axis.text.y = element_blank()) + 
theme(axis.title.y = element_blank()) + 
theme(axis.text.x = element_blank()) +
theme(legend.position = "none"))
4

1 回答 1

0

尽管您的大部分代码都不起作用并且不可重现,但将“红色”更改为“5182BA”似乎可以正常工作。

ggplot(bay, aes(x=medprice.n2, y=wbi)) + 
    geom_smooth(method=lm, size=1.3, colour="#5182BA")
于 2013-07-03T11:42:30.673 回答