Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to limit y-axis on box plot to exclude extreme outliers

    Hi,

    I am trying to create a series of box plots for a set of data, but am running into some issues. What I want to do is include extreme outliers in the calculation for my boxplot (e.g. so they are included in the calculation of Q1, median, Q3, etc.) but I don't want outliers above a certain range displayed on my graph. The reasoning behind this is some outliers are so extreme that it makes it impossible to see the actual box plot.

    The current code I am using to generate my boxplot is:
    Code:
    graph box Outdoor Indoor, ylabel(0[20000]100000)
    And the outputted graph I am getting from this code is:
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	22.8 KB
ID:	1329012

    So what I would like to do is limit the maximum value displayed on the y-axis to 100000 (as I attempted to do with ylabel).

    Thanks so much in advance,

    Stephanie
    Last edited by Stephanie Cleland; 02 Mar 2016, 11:32.

  • #2
    You could specify the nooutsides option which would not plot any of the outside values. Alternatively, you could try a log scale yscale(log) if that makes sense.
    Stata/MP 14.1 (64-bit x86-64)
    Revision 19 May 2016
    Win 8.1

    Comment


    • #3
      yscale(log) may not do what you think it does. I've seen people bitten or at least confused by this, so the point is expanded in excruciating detail at http://www.stata.com/support/faqs/gr...ithmic-scales/

      My own take on data like this is that you need to think on a different scale, perhaps logarithmic or cube root or square root. Once you do that, the box plot will be much more informative and won't need radical surgery.

      Comment


      • #4
        Nick Cox Thanks for the reminder about box plots and non-linear transformations! That's a nice FAQ.
        Stata/MP 14.1 (64-bit x86-64)
        Revision 19 May 2016
        Win 8.1

        Comment

        Working...
        X