下面的示例代码生成给定的图:
p <- ggplot(data=dat,
aes(x=X, y=Y, ymin=lo, ymax=hi,
shape=task, colour=task)) +
geom_point(size=3, position=position_dodge(0.5)) +
geom_errorbar(width=0.12, linewidth=0.5, position=position_dodge(0.5)) +
scale_shape_manual(values=c(16,17),
labels=c('A', 'B')) +
scale_colour_brewer(palette='Dark2',
labels=c('A', 'B')) +
scale_x_discrete('X',
labels=c(1, 2, 3, 4)) +
scale_y_continuous('Y', limits=c(6.0, 8.0),
breaks=c(6.0, 6.5, 7.0, 7.5, 8.0)) +
guides(colour=guide_legend(title='Task:'),
shape=guide_legend(title='Task:')) +
ggtitle('Title') +
theme(plot.title=element_text(hjust=0.5),
axis.text=element_text(size=12),
axis.title=element_text(size=14),
legend.text=element_text(size=10)) +
annotate(geom='text', x=1, y=8, label='1.0', color='black') +
annotate(geom='text', x=2, y=8, label='0.93', color='black') +
annotate(geom='text', x=3, y=8, label='0.95', color='black')
p
字符串
的数据
我怎么能在红色标记的地方添加一些文字?谢谢你,谢谢
2条答案
按热度按时间pcww981p1#
我想到了两个选择:
字符串
的数据
型
的
hrysbysz2#
另一个选项是关闭剪裁并使用自定义注解:
字符串
的数据
这里,X和y坐标是相对于绘图面板(即,灰色矩形),使得x = 0是左边缘,x = 1是右边缘。因此,值1.05将超出绘图面板的右边缘。
所用数据(从所讨论的图中近似推断)
型