2011-10-13 123 views
28

我使用ggplot來繪製時間過程數據(固定比例隨着時間的推移對屏幕上的不同對象),並希望使用色帶顯示SE,但色帶本身在頂部和底部邊緣,這使得閱讀圖形有點困難。我一直無法弄清楚如何擺脫這些邊緣線。這裏是我的劇情代碼:ggplot:刪除色帶邊緣的線

ggplot(gaze, aes(Time, Fix, color=Object, fill=Object)) + 
    stat_summary(fun.y="mean", geom="line", size=2) + 
    stat_summary(fun.data="mean_se", geom="ribbon", alpha=.3) 

有什麼建議嗎?

這是一個最小的工作示例。我壓縮我的數據:

Time Object   y  lower  upper 
1 1000  C 0.12453389 0.04510504 0.2039627 
2 1000  T 0.58826856 0.37615078 0.8003864 
3 1000  U 0.09437160 0.03278069 0.1559625 
4 1100  C 0.12140127 0.03943988 0.2033627 
5 1100  T 0.64560823 0.44898727 0.8422292 
6 1100  U 0.06725172 0.01584248 0.1186610 

d <- structure(list(Time = c(1000L, 1000L, 1000L, 1100L, 1100L, 1100L), Object = structure(c(1L, 2L, 3L, 1L, 2L, 3L), .Label = c("C", 
"T", "U"), class = "factor"), y = c(0.12453389, 0.58826856, 0.0943716, 
0.12140127, 0.64560823, 0.06725172), lower = c(0.04510504, 0.37615078, 
0.03278069, 0.03943988, 0.44898727, 0.01584248), upper = c(0.2039627, 
0.8003864, 0.1559625, 0.2033627, 0.8422292, 0.118661)), .Names = c("Time", 
"Object", "y", "lower", "upper"), class = "data.frame", row.names = c("1", 
"2", "3", "4", "5", "6")) 

,這裏是新的圖形代碼:

ggplot(d, aes(Time, y, color=Object, fill=Object)) + 
    geom_line(size=2) + 
    geom_ribbon(aes(ymin=lower, ymax=upper), alpha=.3, colour=NA) 
+0

你構建一個最小的工作示例。這意味着你應該添加一些簡單的數據來運行你的圖形命令。 – csgillespie

+0

謝謝,這似乎有所幫助。 –

回答

36

您可以使用colour參數刪除邊框

ggplot(d, aes(Time, y, fill=Object)) + 
    geom_line(size=2, aes(colour = Object)) + 
    geom_ribbon(aes(ymin=lower, ymax=upper), alpha=.3) 
2

在這裏你去:

ggplot(d, aes(Time, y, color=Object, fill=Object)) + 
    geom_line(size=2) + 
    geom_ribbon(aes(ymin=lower, ymax=upper), alpha=.3) 
15

geom_ribbon理解linetype審美。只要給它NA,像這樣:

ggplot(d, aes(Time, y, color=Object, fill=Object)) + 
    geom_line(size=2) + 
    geom_ribbon(aes(ymin=lower, ymax=upper, linetype=NA), alpha=.3) 

此處瞭解詳情:http://docs.ggplot2.org/current/geom_ribbon.html

+0

'linetype = NA'不適用於我,但是,'linetype = 0'或'linetype ='blank''工作。 http://ggplot2.tidyverse.org/reference/aes_linetype_size_shape.html – fber