java坐标轴的箭头,在ggplot2中的绘图中添加指向x轴的箭头

该博客使用ggplot2库展示了农业(AG)、金融(FIN)、服务业(SERV)和其他行业(OTHER)在七个合作原则上的百分比差异。通过条形图,可以看出每个行业在各个原则上的增减情况,其中服务业在某些原则上的差异尤为显著。博客还通过在图表底部添加文本和箭头来增强视觉效果。
摘要由CSDN通过智能技术生成

df

7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L,

3L, 4L, 5L, 6L, 7L), .Label = c("principle 1", "principle 2",

"principle 3", "principle 4", "principle 5", "principle 6", "principle 7"

), class = "factor"), pctdiff = c(-6.71369900758148, 9.44233503731219,

11.0107840625484, -53.1259224412594, -9.22356636157099, -41.0142340880256,

-9.6288000905822, -55.3759198976217, -19.1012386886889, -75.4996296064581,

-44.7688906852688, -58.5771031808126, 48.9559446961189, 4.52522805921763,

29.4368505336144, 51.7181015822617, -2.26377179780978, 48.1990295720174,

57.4736669182075, 8.41689226435695, -15.8983115124042, 30.6261564806236,

79.5018869249509, 87.2542807992621, -15.3228747516659, 13.5915020818539,

48.2301858238767), Sector = c("AG", "AG", "AG", "AG", "AG", "AG",

"AG", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "SERV",

"SERV", "SERV", "SERV", "SERV", "SERV", "SERV", "OTHER", "OTHER",

"OTHER", "OTHER", "OTHER", "OTHER")), .Names = c("principle",

"pctdiff", "Sector"), row.names = c(NA, -27L), class = "data.frame")

library(ggplot2)

library(grid)

p

geom_bar(aes(fill = Sector),position = "dodge", stat="identity",col="black")+

ggtitle("How Differing Sectors Talk about Different Co-operative Principles")+theme(plot.title=element_text(hjust=0.5),panel.border = element_rect(colour = "black", fill=NA, size=1),legend.background = element_rect(color = "black"),legend.position =c(1.10,0.7),plot.margin=unit(c(0.5,3,0.5,0.5),"cm"))+

geom_hline(yintercept = 0)

# Add text in the bottom right corner outside the plotting area

p

grob = grid::textGrob(label = "Text", hjust=0, gp=gpar(col="blue", cex=1.7)),

xmin = 8, xmax = 8, ymin =-90, ymax = -90

)

# Add an arrow in the bottom right corner outside the plotting area

p

grob = linesGrob(arrow=arrow(type="open", ends="first", length=unit(3,"mm")), gp=gpar(col="red", lwd=3)),

xmin = 8.25, xmax = 8.5, ymin = -85, ymax = -60

)

# Turn off panel clipping

gt

gt$layout$clip[gt$layout$name == "panel"]

grid.draw(gt)

AVNK6.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值