[R] Missing x label in barplot

PIKAL Petr petr@p|k@| @end|ng |rom prechez@@cz
Thu May 14 08:16:30 CEST 2020


Hi

Not enough space for labels in x axes. Change width.

for (i in 1:3){
  file_name <- paste("clim_bug", i, ".tiff", sep="")
  tiff(file_name, width=520)
barplot(clim[,i+1], ylab="Daily rainfall (mm)", xlab="Time (month)",
        main="Climatological Mean",
        names.arg=c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
"Aug", "Sep", "Oct","Nov","Dec"),
        col="cadetblue3", cex.axis = 1, ylim=c(0,120))
dev.off()
}

Cheers
Petr

> -----Original Message-----
> From: R-help <r-help-bounces using r-project.org> On Behalf Of ani jaya
> Sent: Thursday, May 14, 2020 7:41 AM
> To: r-help <r-help using r-project.org>
> Subject: [R] Missing x label in barplot
> 
> Dear R community,
> 
> I found some missing x label when I saving this plot to tiff file:
> 
> justsample <- rnorm(n=1095*3,mean=100,sd=10)
> justsample <- as.data.frame(matrix(justsample,ncol=3))
> dd <- seq(from=as.Date("1985-01-01"), to =as.Date("1987-12-31"), by='day')
> y <- data.frame(Year=substr(dd,1,4),
>               Month=substr(dd,6,7),
>               Day=substr(dd,9,10), stringsAsFactors = FALSE)
> 
> 
> clim <- aggregate(justsample,list(y$Month),mean,na.rm=TRUE)
> for (i in 1:3){
>   file_name <- paste("clim_bug", i, ".tiff", sep="")
>   tiff(file_name)
> barplot(clim[,i+1], ylab="Daily rainfall (mm)", xlab="Time (month)",
>         main="Climatological Mean",
>         names.arg=c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
> "Aug", "Sep", "Oct","Nov","Dec"),
>         col="cadetblue3", cex.axis = 1, ylim=c(0,120))
> dev.off()
> }
> 
> I can see complete x label in plots window in RStudio and I thought it
> was RStudio error
> but I also have some error in Rgui.
> 
> I believe my code is terrible and as newbie R, I welcome to any
> suggestions and comments.
> 
> 
> > sessionInfo()
> R version 3.6.3 (2020-02-29)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> Running under: Windows 10 x64 (build 18363)
> 
> 
> Best,
> Ani
> 
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.


More information about the R-help mailing list