Announcement

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

  • Extending length whiskers in violinplot

    Hello,

    I'm trying to visualize data of a 'score' variable for two different groups. I used the SSC command violinplot in Stata 17.0 to create a violin plot on the small dataset. The dataset only contains the 'scores' for the two different groups: pre01 and post01.

    Part of the dataset:
    pre01 post01
    45 55
    30 75
    40 50
    45 80
    60 65

    I used the following code:
    Code:
    . violinplot pre01 post01, fill vertical absolute rag(spread(30) msymbol(o) mcolor(%40) mlc(%0) pstyle(p2)) ylabel(, nogrid) whiskers box median colors(sb)
    This results in the following violin plot:
    Violinplot.png

    However, I want to extend the length of the whiskers to go from the largest value (max) to the smallest value (min), instead of the 1.5 IQR rule.

    How should I change my code to accomplish this?

    Many thanks in advance!

    Best,
    Laura

  • #2
    The help file for -violinplot- (from SSC, author Ben Jann), suggests that the whiskers are defined, in part, by the range defined by the "box" (e.g., the interquartile range). I don't see an option that explicitly overrides this rule to span the min/max range. However, you could use the option -tight- that will limit the density plot to not extend beyond the min/max value, and so the density then shows the range of the observed data.

    Comment


    • #3
      Is it possible to post all the data to allow wider discussion? My bias is that the graph shown in #1 makes it really hard to see the data, which for me is the first priority. But seeing only a small subset makes it difficult to guess at how any design would perform for the fuller dataset.

      Also, names like pre01 and post01 suggest a paired structure, which isn't respected by posting marginal distributions.

      See https://www.statalist.org/forums/for...s-for-boxplots for essentially the same issues.

      Comment

      Working...
      X