Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 在条形图的固定点中添加图像_R_Ggplot2_Data Visualization_Ggimage - Fatal编程技术网

R 在条形图的固定点中添加图像

R 在条形图的固定点中添加图像,r,ggplot2,data-visualization,ggimage,R,Ggplot2,Data Visualization,Ggimage,如何将箭头的图像移动到2004栏上? 提前谢谢 这是我的代码: data %>% ggplot(aes(x=year, y=value, fill = gender)) + geom_bar(stat = "identity") + scale_fill_manual(values= c('#1380c9', '#ff6262')) + scale_y_continuous(limits=c(0, 1000)) + theme(axis.text.x = eleme

如何将箭头的图像移动到2004栏上? 提前谢谢

这是我的代码:

data %>% 
  ggplot(aes(x=year, y=value, fill = gender)) +
  geom_bar(stat = "identity") +
  scale_fill_manual(values= c('#1380c9', '#ff6262')) +
  scale_y_continuous(limits=c(0, 1000)) +
  theme(axis.text.x = element_text(angle = 45, hjust = 1, size=8))+
  annotation_custom(rasterGrob(image, interpolate=TRUE, height = 0.08, width = 0.08))

您可以使用注释自定义中的xmin、xmax、ymin和ymax参数指定图像的位置和大小。只需在rasterGrob中保留默认大小设置

图书馆GGPLOT2 图书馆网格 数据%>% ggplotaesx=年份,y=值,填充=性别+ geom_barstat=标识+ 刻度\填充\手动值=c'1380c9','ff6262'+ 比例y连续极限=c0,1000+ themeaxis.text.x=element\u textangle=45,hjust=1,size=8+ 注释_customrasterGrobimage,插值=真, xmin=3.6,xmax=5.5,ymin=700,ymax=850 当然,我没有您的数据或相同的箭头图形,但这给了我:

以下是我使用的数据:

数据