在GGPLOT中替换X轴tick和具有百分位等级的文本
我目前正在尝试复制以下图: 要复制的情节
我正在用代替x-axis tick ticks和文本是百分位等级而不是国家ISO(本质上是在“要复制的情节”中复制x轴)。
我目前在此图像中处于舞台上:尝试复制
我正在使用以下代码:
ggplot(data, aes(x = x, y = y)) +
geom_errorbar(aes(ymax = Cup, ymin = Cdo)) +
labs(x = "Country ISO",
y = "Transparency Rating",
title = "Transparency Index with CI") +
theme_light() +
theme(panel.grid.major.x = element_blank() ,
panel.grid.major.y = element_line( size=.05, color="grey")
)
i i尝试使用具有各种输入的选项,但我似乎可以使其起作用:
theme(axis.ticks.x = ,
axis.text.x =)
)
一些数据对您的复制有用:
x<-c("AFG","ALB","ITA",
"IND","AGO","ARE",
"ATG","BEN","BFA",
"BGD","BGR","BHR",
"BHS","BIH","BRB",
"BRN","BTN","BWA",
"CAF","CAN")
y<-c(1:20)
Cup<-y+0.4
Cdo<-y-0.4
data<- data.frame(x,y,Cup,Cdo)
对于那些还可以告诉我如何在正确点上添加某些特定国家名称的人,像“要复制”中的情节一样。
非常感谢您的帮助!
I am currently trying to reproduce the following graph:
Plot to be replicated
What I am struggling with is substituting the x-axis ticks and text to be the percentile rank rather than the country ISO (essentially replicating the x-axis in the "Plot to be replicated").
I am currently at the stage in this image: Attempted Replication
I am using the following code:
ggplot(data, aes(x = x, y = y)) +
geom_errorbar(aes(ymax = Cup, ymin = Cdo)) +
labs(x = "Country ISO",
y = "Transparency Rating",
title = "Transparency Index with CI") +
theme_light() +
theme(panel.grid.major.x = element_blank() ,
panel.grid.major.y = element_line( size=.05, color="grey")
)
I tried to use the options with various inputs but I can seem to make it work:
theme(axis.ticks.x = ,
axis.text.x =)
)
Some data useful for your replication:
x<-c("AFG","ALB","ITA",
"IND","AGO","ARE",
"ATG","BEN","BFA",
"BGD","BGR","BHR",
"BHS","BIH","BRB",
"BRN","BTN","BWA",
"CAF","CAN")
y<-c(1:20)
Cup<-y+0.4
Cdo<-y-0.4
data<- data.frame(x,y,Cup,Cdo)
Extra points for those who can also tell me how to add certain specific country names at the right point inside of the plot like in the "Plot to be replicated".
Thank you so much for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
包括选择性国家标签:
在2022-05-24创建的 reprex软件包(v2.0.1)
Includes selective country labelling:
Created on 2022-05-24 by the reprex package (v2.0.1)