Announcement

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

  • How to produce this type of graph?

    Hi,

    I saw this graph in an article and I wonder if it can be produced by Stata.
    Shamefully, I do not know the name of the graph!!

    Click image for larger version

Name:	777.PNG
Views:	1
Size:	188.9 KB
ID:	1572531


    Appreciating your help.

    Thanks.
    Anna

  • #2
    Many names exist. Perhaps strip plot or strip chart is the most common now. Note also jitter plot.

    You don't explain much about the detail. Sample sizes are easy enough. Whether m means mean, median or something else is unclear. The percents are something else. I wasn't smart enough to guess at them.

    To show technique, I invented an example and used stripplot from SSC. The help file documents many more names, perhaps about 30.


    Code:
    clear
    input freq m
    8    7.69
    69   6.92
    462  7.04
    570  7.01
    648  6.78
    780  6.76
    536  6.57
    405  6.69
    427  7.06
    148  7.21
    end
    gen age = _n - 1
    local lower 0
    forval j = 0/9 {
        local upper = `lower' + 9
        label def age `j' "`lower'-`upper'", modify
        local lower = `lower' + 10
    }
    label val age age
    expand freq
    set seed 2803
    gen value = m + rnormal(0,1)
    gen ywhere = 2.8
    gen xwhere = age - 0.2
    gen show = "{it:n} =" + string(freq)
    
    stripplot value, vertical ms(oh) mc(red%30)  msize(small) over(age) jitter(8) yla(3/10, ang(h)) refline(lw(medthick)) reflinestretch(0.4) addplot(scatter ywhere age, mlabel(show) mlabpos(0) ms(none)) xla(, noticks)




    Click image for larger version

Name:	jitterplot.png
Views:	1
Size:	207.8 KB
ID:	1572541



    FWIW, I think this design is a little oversold.

    Here is another of many more possibilities.

    Code:
    stripplot value, vertical ms(oh) mc(red%30)  msize(small) over(age) stack width(0.05) yla(3/10, ang(h)) refline(lw(medthick)) reflinestretch(0.1) addplot(scatter ywhere age, mlabel(show) mlabpos(0) ms(none)) xla(, noticks)
    Click image for larger version

Name:	jitterplot2.png
Views:	1
Size:	122.8 KB
ID:	1572542

    Last edited by Nick Cox; 12 Sep 2020, 11:51.

    Comment


    • #3
      Many many thanks!!

      I am sorry for not giving enough details but your explanation is more than enough and is so helpful.

      Thanks again.

      Comment


      • #4
        Understood! By the way, whether the graph shows (a) data like yours or (b) data nothing like yours, but you just want a similar graph, I would comment that binning here looks remarkably arbitrary.

        Guessing that we are seeing data on people, not chimpanzees or electric light bulbs, nothing special happened at ages 10 20 30 40 50 60 to me or anyone else I know except for recognition of yet another birthday by people close to me. (Still working at 70 80 90.) Directly put, why bin here at all? Presumably the underlying data are (age, value) pairs, so the best exploratory graphic would be more likely to be based on scatter plot smoothing.

        Comment

        Working...
        X