簡體   English   中英

圖形沒有ggplot

[英]Graphic no ggplot

我需要幫助才能使用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)

如果可能,請提供數據集,因此關鍵是將您的月份或列設置為一個因子,使用 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()

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM