Announcement

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

  • Dot Plot with Multiple Categories

    Hello,
    I'm looking to create a dot plot over multiple categories. It is survey data, and I want to graph the mean response variable over certain respondent characteristics. For example, a correspondent characteristic is sex and age group.

    Code:
    graph dot (mean) response_1 response_2, over(sex)
    Gives me what I want, but I can only specify over sex. I'd like to have by sex and age group in the same graph.
    Apologies in advance for not having a dataex.

  • #2
    Code:
    . sysuse auto, clear
    (1978 automobile data)
    
    . graph dot mpg, over(foreign) over(rep78)
    
    . graph dot turn trunk, over(foreign) over(rep78)

    Comment


    • #3
      Hi Nick, thanks for the response. I've tried this, but this gives subcategories, right? The intersections of all the variables (e.g. young female, old female, old man, old female). I'd just like old, young, female, man

      Comment


      • #4
        here is a dataex

        Code:
        * Example generated by -dataex-. For more info, type help dataex
        clear
        input byte sex float(political response_1) double response_2
        2 4 -30.1 13.700000000000001
        2 4   4.9 13.700000000000001
        2 5 -10.1 13.700000000000001
        1 4  14.9 13.700000000000001
        2 2   4.9 13.700000000000001
        2 4  24.9 13.700000000000001
        1 2 -15.1 13.700000000000001
        2 1  14.9 13.700000000000001
        1 4   4.9 13.700000000000001
        2 4  14.9 13.700000000000001
        1 5  34.9 13.700000000000001
        2 3  -5.1 13.700000000000001
        1 4  24.9 13.700000000000001
        2 4 -15.1 13.700000000000001
        1 4  34.9 13.700000000000001
        2 2   -.1 13.700000000000001
        2 4  24.9 13.700000000000001
        1 3  -5.1 13.700000000000001
        2 6  64.9 13.700000000000001
        1 1  34.9 13.700000000000001
        2 2 -25.1 13.700000000000001
        2 5 -20.1 13.700000000000001
        2 4  24.9 13.700000000000001
        2 4 -15.1 13.700000000000001
        1 0 -25.1 13.700000000000001
        1 1 -25.1 13.700000000000001
        1 2  14.9 13.700000000000001
        2 4  -5.1 13.700000000000001
        2 2  14.9 13.700000000000001
        1 3   9.9 13.700000000000001
        1 1 -33.1 13.700000000000001
        1 4  44.9 13.700000000000001
        1 4  21.9 13.700000000000001
        1 2   4.9 13.700000000000001
        1 5  14.9 13.700000000000001
        2 1 -15.1 13.700000000000001
        2 4   9.9 13.700000000000001
        2 4 -30.1 13.700000000000001
        2 3 -10.1 13.700000000000001
        2 2 -15.1 13.700000000000001
        2 5 -25.1 13.700000000000001
        1 4 -15.1 13.700000000000001
        2 4  14.9 13.700000000000001
        2 4  14.9 13.700000000000001
        2 2  34.9 13.700000000000001
        2 1  -5.1 13.700000000000001
        1 5 -30.1 13.700000000000001
        1 3  29.9 13.700000000000001
        1 5  54.9 13.700000000000001
        1 4 -15.1 13.700000000000001
        1 4  14.9 13.700000000000001
        2 4 -10.1 13.700000000000001
        2 3   4.9 13.700000000000001
        2 2   4.9 13.700000000000001
        1 4 -15.1 13.700000000000001
        1 5 -12.1 13.700000000000001
        1 4   4.9 13.700000000000001
        1 4  34.9 13.700000000000001
        1 5   4.9 13.700000000000001
        1 2  14.9 13.700000000000001
        1 1  60.9 13.700000000000001
        2 5  -5.1 13.700000000000001
        1 5  39.9 13.700000000000001
        1 1 -33.1 13.700000000000001
        1 5  14.9 13.700000000000001
        2 1  59.9 13.700000000000001
        1 4 -10.1 13.700000000000001
        1 5 -15.1 13.700000000000001
        2 4 -25.1 13.700000000000001
        2 5 -25.1 13.700000000000001
        1 4 -20.1 13.700000000000001
        2 4   4.9 13.700000000000001
        1 4  14.9 13.700000000000001
        2 4 -15.1 13.700000000000001
        2 4  34.9 13.700000000000001
        2 2  14.9 13.700000000000001
        2 6  14.9 13.700000000000001
        1 4  59.9 13.700000000000001
        2 4  24.9 13.700000000000001
        2 6 -25.1 13.700000000000001
        2 3  14.9 13.700000000000001
        2 5 -15.1 13.700000000000001
        1 5   4.9 13.700000000000001
        1 0  -5.1 13.700000000000001
        1 4  -5.1 13.700000000000001
        2 5 -30.1 13.700000000000001
        2 4 -30.1 13.700000000000001
        1 4  24.9 13.700000000000001
        2 5 -15.1 13.700000000000001
        2 2  14.9 13.700000000000001
        1 3   4.9 13.700000000000001
        1 4 -34.1 13.700000000000001
        1 2   4.9 13.700000000000001
        2 4 -15.1 13.700000000000001
        2 4  14.9 13.700000000000001
        1 2 -20.1 13.700000000000001
        1 5   -.1 13.700000000000001
        1 1 -20.1 13.700000000000001
        2 2 -14.1 13.700000000000001
        1 4  -5.1 13.700000000000001
        end
        label values sex sex
        label def sex 1 "Male", modify
        label def sex 2 "Female", modify
        label values political vote
        label def vote  0 "NA", modify
        label def vote 1 "R", modify
        label def vote  2 "CR", modify
        label def vote 3 "C", modify
        label def vote  4 "CL", modify
        label def vote  5 "L", modify
        label def vote  6 "O", modify
        Last edited by John Singer; 28 Jan 2022, 04:58.

        Comment


        • #5
          You can do separate graphs and then graph combine. Alternatively, see https://www.stata-journal.com/articl...article=gr0058

          Comment

          Working...
          X