2013-07-02 56 views
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")) 

回答

0

雖然大部分代碼不起作用,並且不可重現,但將「red」更改爲「5182BA」似乎工作正常。

ggplot(bay, aes(x=medprice.n2, y=wbi)) + 
    geom_smooth(method=lm, size=1.3, colour="#5182BA") 
+0

對於發佈不可重現的代碼,我表示抱歉。學過的知識。感謝解決方案,現在奇怪的解決方案以前似乎沒有這樣做。 – user2317662

相關問題