Announcement

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

  • Graphing several variables over multiple discrete categories

    Hi, I'm graphing the value of 3 variables in several scenarios as displayed below. Each of these scenarios can be broken down into 4 different categories (A, B, C, D) each with several cases.
    Click image for larger version

Name:	A.png
Views:	1
Size:	70.2 KB
ID:	1559027



    1) Do you have any suggestions on how to better present the data, specially if instead of having 16 scenarios I have more than 100 (still broken down in the same 4 categories)? I would like to have the variables Case 1-3 on the same panel so they can be easily compared.
    -With graph dot you can't graph over more than 2 categories (maybe mulidot will be more flexible with an alternative solution?)

    2) What if I wanted to make an additional graph to present variables Case 1-3 in one panel, Case 4-6 in another panel and Case 7-9 in another panel in the same graph?

    Here is the data and code I'm using:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(w_total_ex11_1 w_total_ex11_2 w_total_ex11_3) str12 context
    1 .9967358 .9898894 "A1 B.1 C1 D1"
    1 .9967358 .9898894 "A1 B.1 C2 D1"
    1 .9967358 .9898894 "A1 B.1 C1 D2"
    1 .9967358 .9898894 "A1 B.1 C2 D2"
    1 .9943715 .9825519 "A1 B1 C1 D1"
    1 .9943715 .9825519 "A1 B1 C2 D1"
    1 .9943715 .9825519 "A1 B1 C1 D2"
    1 .9943715 .9825519 "A1 B1 C2 D2"
    1 .9640673 .8842497 "A2 B.1 C1 D1"
    1 .9640673 .8842497 "A2 B.1 C2 D1"
    1 .9640675 .8842502 "A2 B.1 C1 D2"
    1 .9640675 .8842502 "A2 B.1 C2 D2"
    1 .9556586  .850899 "A2 B1 C1 D1"
    1 .9556586  .850899 "A2 B1 C2 D1"
    1 .9556586  .850899 "A2 B1 C1 D2"
    1 .9556586  .850899 "A2 B1 C2 D2"
    end
    
    graph dot w_total_ex11_1 w_total_ex11_2 w_total_ex11_3 , over(context) nofill ///
            ndots(80) ytitle("(%)") ylabel(,format(%3.1fc))  xsize(10) ysize(6) ///
            marker(1, mlcolor(navy)) marker(2, mcolor(maroon) msymbol(T)) marker(3, mcolor(forest_green) msymbol(S)) ///
            legend(order(1 "Case 1" 2 "Case 2" 3 "Case 3")) ///
            graphregion(color(white) margin(zero)) scheme(s1color)
    Thanks for any suggestion!
    Last edited by Santiago Cantillo; 15 Jun 2020, 19:05.

  • #2
    I have various small suggestions.

    1. These data look to me like proportions. If so, the title text % is incorrect.

    2. On the evidence here you don't need to show zero.

    3. I've found that a grid of dotted lines can often degrade when a graph is ported to other software. Thin grey lines work well, or at least I've not heard any objections.

    4. It's not an issue here, but open marker symbols tolerate overlap and occlusion better than solid.

    I can imagine perhaps 3 more such graphs in a 2 x 2 display, but not many more if you want graphs to remain readable.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(w_total_ex11_1 w_total_ex11_2 w_total_ex11_3) str12 context
    1 .9967358 .9898894 "A1 B.1 C1 D1"
    1 .9967358 .9898894 "A1 B.1 C2 D1"
    1 .9967358 .9898894 "A1 B.1 C1 D2"
    1 .9967358 .9898894 "A1 B.1 C2 D2"
    1 .9943715 .9825519 "A1 B1 C1 D1"
    1 .9943715 .9825519 "A1 B1 C2 D1"
    1 .9943715 .9825519 "A1 B1 C1 D2"
    1 .9943715 .9825519 "A1 B1 C2 D2"
    1 .9640673 .8842497 "A2 B.1 C1 D1"
    1 .9640673 .8842497 "A2 B.1 C2 D1"
    1 .9640675 .8842502 "A2 B.1 C1 D2"
    1 .9640675 .8842502 "A2 B.1 C2 D2"
    1 .9556586  .850899 "A2 B1 C1 D1"
    1 .9556586  .850899 "A2 B1 C2 D1"
    1 .9556586  .850899 "A2 B1 C1 D2"
    1 .9556586  .850899 "A2 B1 C2 D2"
    end
    
    graph dot w_total_ex11_1 w_total_ex11_2 w_total_ex11_3 , over(context) nofill ///
            ytitle("proportion") ylabel(0.8(0.05)1,format(%3.2fc))  xsize(10) ysize(6) ///
            marker(1, ms(+) mlcolor(navy)) marker(2, mcolor(maroon) msymbol(Th)) marker(3, mcolor(forest_green) msymbol(Sh)) ///
            legend(order(3 "Case 3" 2 "Case 2" 3 "Case 1") row(1)) exclude0 ///
            graphregion(color(white) margin(zero)) scheme(s1color) linetype(line) lines(lc(gs12) lw(thin))
    Click image for larger version

Name:	santiago.png
Views:	1
Size:	26.6 KB
ID:	1559055

    Comment


    • #3
      Detail: the legend would be better with


      Code:
       legend(order(3 "Case 3" 2 "Case 2" 1 "Case 1") row(1))

      Comment


      • #4
        Thanks Nick, good suggestions!
        In the case where I might have +100 scenarios, would you have any suggestion? (of course the real data wouldn't follow such a smooth pattern)
        Note that each scenario can be divided into 4 categories, could this be exploited?
        Click image for larger version

Name:	B.png
Views:	1
Size:	50.1 KB
ID:	1559147

        Code:
        * Example generated by -dataex-. To install: ssc install dataex
        clear
        input float(w_total_ex11_1 w_total_ex11_2 w_total_ex11_3) str12 context
        1 .9967358 .9898894 "A1 B.1 C1 D1"
        1 .9967358 .9898894 "A1 B.1 C2 D1"
        1 .9967358 .9898894 "A1 B.1 C1 D2"
        1 .9967358 .9898894 "A1 B.1 C2 D2"
        1 .9943715 .9825519 "A1 B1 C1 D1" 
        1 .9943715 .9825519 "A1 B1 C2 D1" 
        1 .9943715 .9825519 "A1 B1 C1 D2" 
        1 .9943715 .9825519 "A1 B1 C2 D2" 
        1 .9640673 .8842497 "A2 B.1 C1 D1"
        1 .9640673 .8842497 "A2 B.1 C2 D1"
        1 .9640675 .8842502 "A2 B.1 C1 D2"
        1 .9640675 .8842502 "A2 B.1 C2 D2"
        1 .9556586  .850899 "A2 B1 C1 D1" 
        1 .9556586  .850899 "A2 B1 C2 D1" 
        1 .9556586  .850899 "A2 B1 C1 D2" 
        1 .9556586  .850899 "A2 B1 C2 D2" 
        end
        
        expand 8, gen(new)
        bys context: gen n = _n
        gen context1 = context + " E" + string(n)
        
        graph dot w_total_ex11_1 w_total_ex11_2 w_total_ex11_3 , over(context1, label(labsize(*0.3))) nofill ///
                ytitle("proportion") ylabel(0.8(0.05)1,format(%3.2fc))  xsize(10) ysize(6) ///
                marker(1, ms(+) mlcolor(navy) msize(*0.2)) marker(2, mcolor(maroon) msymbol(Th) msize(*0.2)) marker(3, mcolor(forest_green) msymbol(Sh) msize(*0.2)) ///
                legend(order(3 "Case 3" 2 "Case 2" 3 "Case 1") row(1)) exclude0 ///
                graphregion(color(white) margin(zero)) scheme(s1color) linetype(line) lines(lc(gs12) lw(*0.2))

        Comment


        • #5
          You seem to have four distinct groups here, which can be plotted, although for once it's arguable that a table of values would be preferable as well as clearer.

          There is a question only you can answer: how far would readers of this care (e.g) that one value is 0.850899. I am not being facetious or disrespectful, just genuinely ignorant of what is being shown here.

          Which groups include which detail should perhaps be separated off into text tables, as to me the vertical axis text is utterly unreadable.

          Comment

          Working...
          X