我需要帮助来用ggplot2制作这个图形:

我不知道如何将月份放在x轴上,也不能正确地将数据放在y轴上。我的数据大小不一。
我正在尝试使用以下代码:
dados1 <-read.table("dados.txt", header=TRUE)
registro<-dados1$Registro
ggplot(dados1, aes(x = registro)) +
geom_histogram(colour="black", breaks = seq(0,12), closed="left") +
labs (title = "RS030", subtitle = "") +
coord_polar(theta="x",start=0, direction = 1) +
scale_x_continuous(name="",limits=c(0,12),breaks=0:12, labels=0:12, position = "bottom")+
scale_y_continuous(name="", limits = c(0,16),breaks= seq(0,16,by=4),
labels =seq(0,16,by=4), position = "right")+
theme_minimal()+
theme(plot.title=element_text(size=14), plot.subtitle=element_text(size=10),
panel.grid = element_line(colour="gray", linetype=1, size=0),
panel.grid.major.x = element_line(colour="gray", linetype=1, size=0),
panel.background = element_rect(colour="white", fill="white"),
text=element_text(size=11),
axis.text.x = element_text(face="bold", color="black",size=10),
axis.text.y = element_blank())+
annotate("text",label = seq(0,16,4),
x = 12, y=seq(0,16,4),
color="black", size=3,
fontface="plain",hjust=1,vjust=1)发布于 2020-04-07 05:53:22
如果可能,请提供数据集,因此关键是将您的月份或列设置为因子,使用geom_bar()来计算因子(比使用直方图好得多),最后您需要引入设置-ve值的限制,以便条形图向上推。你可以试着这样开始:
library(ggplot2)
set.seed(111)
dados1 = data.frame(Registro=sample(1:12,100,replace=TRUE))
YLIM = max(table(dados1$Registro))
ggplot(dados1, aes(x = factor(Registro))) +
geom_bar(colour="black",stat="count",width=0.5,fill="#00bcd4") +
ylim(c(-YLIM/2,YLIM))+
labs (title = "RS030", subtitle = "") +
coord_polar(theta="x",start=0, direction = 1) +
scale_x_discrete(name="",breaks=1:12,
labels=month.abb, position = "bottom")+
theme_bw()

https://stackoverflow.com/questions/61061202
复制相似问题