在下面的小例子中,我已经设法让我的情节看起来像我想要的,除了在图例中获得正确的形状.有什么需要帮忙的吗?
没有guides(shape='none')
,我得到了两个传说,一个是彩色的,另一个是形状的.它们如何结合在一起呢?
require(ggplot2)
dat = data.frame(
Type = c('T1', 'T1', 'T2', 'T2', 'T3', 'T3'),
Condition = c('C1', 'C2', 'C1', 'C2', 'C1', 'C2'),
Estimate = c(12.9, 13.4, 13.1, 13.6, 13.1, 13.8),
lo95CI = c(12.0, 12.5, 12.2, 12.7, 12.1, 12.8),
hi95CI = c(14.0, 14.5, 14.2, 14.7, 14.1, 14.8),
Data = c(0.9, 1.1, 1.9, 2.1, 2.9, 3.1)
)
p1 <- ggplot(data=dat,
aes(x=Data, y=Estimate, group=Condition)) +
coord_cartesian(ylim=c(11,15)) +
geom_point(aes(shape=Condition, colour=Condition), size=3) +
geom_errorbar(width=.12, linewidth=.5,
aes(ymin=lo95CI, ymax=hi95CI, colour=Condition)) +
scale_colour_brewer('Task:', palette='Dark2') +
scale_x_continuous('Stimulus Type',
breaks=c(1, 2, 3, 4),
labels=c('T1', 'T2', 'T3', 'T4')) +
scale_y_continuous('DV') +
guides(shape='none') +
theme(axis.text=element_text(size=12),
axis.title=element_text(size=14),
legend.text=element_text(size=10),
plot.title=element_text(hjust=0.5))
p1