Hi,

to hide the axis generated by bxp you have to set axes=FALSE and frame.plot=FALSE and then you can plot the x-axis by using the axis() function

example:

boxplot(len ~ dose, data = ToothGrowth,
   frame.plot=FALSE,axes=FALSE,
       boxwex = 0.25, at = 1:3 - 0.2,
       subset = supp == "VC", col = "yellow",
       main = "Guinea Pigs' Tooth Growth",
       xlab = "Vitamin C dose mg",
       ylab = "tooth length",
       xlim = c(0.5, 3.5), ylim = c(0, 35))
boxplot(len ~ dose, data = ToothGrowth, add = TRUE,
   frame.plot=FALSE,axes=FALSE,
       boxwex = 0.25, at = 1:3 + 0.2,
       subset = supp == "OJ", col = "orange")
axis(1,at=0:4)
axis(2,at=(0:17)*2)
legend(2, 9, c("Ascorbic acid", "Orange juice"),
      fill = c("yellow", "orange"))

Theresa


Tim Clark wrote:
Dear List,
I am creating a boxplot with two subsets, very similar to the example by Roger Bivand at ?boxplot (reproduced below). I am trying to change the labels on the x-axis to have one number to cover both subsets. I can do this in other plots by using axis=FALSE followed by a separate axis() command. I have also tried variations in the names= argument but can't get it to work. Ideally I would like tickmarks on either side of each factor with the number for the level centered between the two tick marks. Any suggestions? Thanks, Tim
Example:

boxplot(len ~ dose, data = ToothGrowth,
        boxwex = 0.25, at = 1:3 - 0.2,
        subset = supp == "VC", col = "yellow",
        main = "Guinea Pigs' Tooth Growth",
        xlab = "Vitamin C dose mg",
        ylab = "tooth length",
        xlim = c(0.5, 3.5), ylim = c(0, 35), yaxs = "i")
boxplot(len ~ dose, data = ToothGrowth, add = TRUE,
        boxwex = 0.25, at = 1:3 + 0.2,
        subset = supp == "OJ", col = "orange")
legend(2, 9, c("Ascorbic acid", "Orange juice"),
       fill = c("yellow", "orange"))


 Tim Clark

Marine Ecologist
National Park of American Samoa


______________________________________________
R-help@r-project.org mailing list
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.



______________________________________________
R-help@r-project.org mailing list
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.

Reply via email to