简体   繁体   中英

R Boxplot two rows at x-axis

I try to draw a boxplot with two rows of numbers on the x-axis. 在此处输入图片说明

Where #1 is the default and I want it to be like #2. Is it possible to add another row and give it unique ticks and intervalls? So far I tried the axis() function and was trying to find out if it is possible to use rows from excel as axis input.

boxplot(data, yaxp=c(-2,1,6), ylim=c(-2, 1), names=c(1:40), main = "header", xlab="x axis title", ylab="y axis title")

It is possible with axis() . You can choose your own labels. The line argument changes the distance from the original ticks.

boxplot(mpg ~ cyl,
        data = mtcars, 
        main = "Car Milage Data", 
        xlab = "Number of Cylinders", ylab = "Miles Per Gallon")
axis(side = 1, line = 1, at = c(1, 2, 3), labels = c("A", "B", "C"), tick = F)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM