Search code examples
rmedianboxplot

Boxplot in R with only median visible


I want to plot only median for my two dataset. It can be also done using segments function in R but I don't know how. So, I decided using boxplot function but still couldn't figure out how to hide everything and show just medians.

Thanks


Solution

  • You can set the graphical parameters which are documented under ?bxp:

    boxlty: box outline type
    whisklty: whisker line type
    staplelty: staple (= end of whisker) line type
    

    Setting outline = FALSE suppresses drawing outliers.

    boxplot(count ~ spray, data = InsectSprays, outline = FALSE, boxlty = 0,
      whisklty = 0, staplelty = 0)
    

    should draw a boxplot with just the horizontal lines at the medians.