Y axis from the printable area in dash font () to R

I'm having trouble getting the y axis in the horizontal panel () in the plot area. See this example, I thought that using ylim and / or yaxp would stop this if you leave the plotting area, but it doesn't seem to work.

I tried to reproduce the set that I have:

x <- matrix(abs(rnorm(34)), nrow = 34, ncol = 3)
rownames(x) <- c(seq(0,6600,200))
barplot(x[,3], horiz=TRUE, space = 0.4, main = "Title", las=1, cex.names=0.8, ylab="y label")

But the axis comes from the build area if I add ylim:

barplot(x[,3], horiz=TRUE, space = 0.4, ylim = c(0,25), yaxp=c(0,25,1), main = "Title", las=1, cex.names=0.8, ylab="y label")
+3
source share
2 answers

The key here is to forget about ylim when using barplot and instead just send the desired print range in the data:

barplot(x[1:25,3], horiz=TRUE,  space = 0.4,  yaxp=c(0,25,1), main = "Title", las=1,  
          cex.names=0.8, ylab="y label")

Also note that indexing in R starts at 1, not 0, as it might be in some other languages.

+3

- (?) , barplot xpd = T , false , , :

barplot(x[,3], horiz=TRUE, space = 0.4, ylim = c(0,25), yaxp=c(0,25,1), main = "Title", las=1, cex.names=0.8, ylab="y label", xpd=F)
+2

Source: https://habr.com/ru/post/1773562/


All Articles