10
我該如何創建一個圖例,告知紅叉十字是什麼意思?ggplot2 stat_summary的圖例
ggplot(results, aes(x=factor, y=proportionPositive)) +
geom_boxplot() +
stat_summary(fun.data = "mean_cl_normal", colour = "red", shape=4)
我該如何創建一個圖例,告知紅叉十字是什麼意思?ggplot2 stat_summary的圖例
ggplot(results, aes(x=factor, y=proportionPositive)) +
geom_boxplot() +
stat_summary(fun.data = "mean_cl_normal", colour = "red", shape=4)
這裏是做的一種方法:
# Create dummy data results <- data.frame( factor=factor(rep(1:10, 100)), proportionPositive=rnorm(1000)) # Plot results ggplot(results, aes(x=factor, y=proportionPositive)) + geom_boxplot() + stat_summary(fun.data = "mean_cl_normal", aes(shape="mean"), colour = "red", geom="point") + scale_shape_manual("", values=c("mean"="x"))
,使它看起來像一個默認的傳說(從@Andrie代碼借款):
ggplot(results, aes(x=factor, y=proportionPositive)) +
geom_boxplot() +
stat_summary(fun.data = "mean_cl_normal",
aes(shape=""), # Leave empty
colour = "red",
geom="point") +
scale_shape_manual("mean", values= "") # Will show mean on top of the line
如果你想使用PCH symbolsl有可能使用Unicode數字。爲了做到這一點,只需用一個Unicode值替換'x':「\ U」然後是Unicode值(例如'「\ U22C4」')。參見[Unicode表] [1] [1]:http://www.fileformat.info/info/unicode/char/22c4/index.htm – Facottons