Placing the x axis on top of the bar chart with negative y values

I have some data for various experimental treatments that are negative. I would like to build the x axis on top of the tablet and overlay the labels just as if it were a traditional bar chart in the center of the bars.

I checked everything and can’t find anything that allows me to name axis labels with words, setting only labels and numbers.

Here's the data: - "wp_means"

>         12         15          3          6          9    Control 
-0.3000000 -0.2416667 -0.3416667 -0.3916667 -0.2750000 -0.2750000 
        DL 
-0.2833333

Here is my code to build the bar. I can omit the x axis from its usual position, but I cannot seem to have it on top with its labels, etc., where I want it to be.

cols<-c("blue1", "cyan","chartreuse","mediumspringgreen","maroon1","orange","red")
    wp<-data.frame(a=c(wp_means),b=c(12,15,3,6,9,"Control","DL"))
    wp$c=factor(wp$b, levels = c("Control",15,"DL",12,9,6,3))
    wp <- wp[order(wp$c), ]
    barplot(height=wp$a,names.arg=wp$c,col=cols,main="Water Potential",las=1,xaxt="n",
    ylab = "Water potential 
    (MPA)",pch=21,bg="black",cex=0.7,cex.lab=0.8,font.lab=2,
    cex.axis=0.7,font.axis=2,cex.main=1,ylim=c(-0.5,0),xaxt="n")

: x , "levels = c("Control"....)", . , , xlab="some name", .

enter image description here

+4
1

, , pos= ?axis barplot. -. , bp <- barplot(...), :

wp_means <- c(-0.3, -0.2, -0.34, -0.39, -0.275, -0.275, -0.283)

cols<-c("blue1", "cyan","chartreuse","mediumspringgreen","maroon1","orange","red")

wp <-data.frame(a=c(wp_means),b=c(12,15,3,6,9,"Control","DL"))

wp$c=factor(wp$b, levels = c("Control",15,"DL",12,9,6,3))
wp <- wp[order(wp$c), ]
bp <- barplot(height=wp$a, names.arg=wp$c, col=cols, las=1, xaxt="n",
         ylab = "Water potential (MPA)",
         pch=21, bg="black", cex=0.7, cex.lab=0.8, font.lab=2,
         cex.axis=0.7, font.axis=2, cex.main=1, ylim=c(-0.5,0), xaxt="n")

axis(side=3, pos=0, at=bp, labels=levels(wp$c))
title(main="Water Potential", line=3)

line=3 title(), .

enter image description here

+4

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


All Articles