Announcement

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

  • Bar chart is displaying space for missing cateogry.

    I need some help with the chart below:

    - how can I avoid that there is a space for the missing category? ( the data below is only showing a 3x3 matrix, but I have also 10x10 and the graph looks weird)
    - How should I rearrange my data to show the two bars of the same color for a single bank next to each other?
    - How can I display the legend on top of each bar?

    Thanks

    Click image for larger version

Name:	France_matrix.png
Views:	1
Size:	26.7 KB
ID:	1556533



    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float date str6 a double(BNP CA SOCGEN) str6 date2
    20164 "BNP"             . .586713291 .595155179 "2015/3"
    22015 "BNP"             . .650374872 .670668198 "2020/4"
    20164 "CA"     .618743833          .  .55202926 "2015/3"
    22015 "CA"     .542818524          . .534340881 "2020/4"
    20164 "SOCGEN" .751988722 .661390955          . "2015/3"
    22015 "SOCGEN" .677377044 .646621673          . "2020/4"
    end
    format %tdnn/dd/YY date
    Code:
    ds date a date2, not
    graph bar (asis) `r(varlist)', over (date2) over(a) graphregion(margin(zero)) graphregion(color(white)) yti(COPOD) nodraw note("NOTE: Each bar is the conditional probability of the bank given the bank indicated in the legend")

  • #2
    Here are some other possibilities:

    Code:
       
        clear
        input float date str6 a double(BNP CA SOCGEN) str6 date2
        20164 "BNP"             . .586713291 .595155179 "2015/3"
        22015 "BNP"             . .650374872 .670668198 "2020/4"
        20164 "CA"     .618743833          .  .55202926 "2015/3"
        22015 "CA"     .542818524          . .534340881 "2020/4"
        20164 "SOCGEN" .751988722 .661390955          . "2015/3"
        22015 "SOCGEN" .677377044 .646621673          . "2020/4"
        end
        format %tdnn/dd/YY date
    
        rename (BNP CA SOCGEN) (COPOD=)
        
        reshape long COPOD, i(a date2) j(which) string
        
        drop if missing(COPOD)
        
        * ssc install tabplot
        tabplot a date2 [iw=COPOD], by(which, note("") subtitle(COPOD)  row(1)) ///
        ytitle("explain this") xtitle("") bfcolor(none) graphregion(margin(zero) color(white)) showval(format(%4.3f)) name(G1)
        
    egen group = group(a date2), label
    
    graph dot (asis) COPOD, over(group) over(which) nofill exclude0 linetype(line) lines(lc(gs12) lw(thin))   yla(0.5(0.1)0.8, format(%02.1f)) name(G2)

    Comment


    • #3
      Thanks Nick, I wasn't aware of these other visualization options.

      Comment


      • #4
        Hi Nick, sorry to get back to this just now, but I would like to know if you could provide some suggestions on the coloring by group.

        I was unable to color the bars in the tabplot or get a decent result with the graph dot. Especially in the graph dot, I lose the horizontal lines for no particular reason

        Code:
        graph dot (asis) COPOD1 COPOD2 COPOD3 COPOD4 COPOD5, over(group, label(labsize(*.6)))nofill exclude0 linetype(line) lines(lc(gs12) lw(thin))  yla(0.1(0.1)0.8, format(%02.1f) )  over(which, label(labsize(*.6))) // graphregion(margin(zero) color(white))
        Click image for larger version

Name:	Graphdot.png
Views:	2
Size:	43.5 KB
ID:	1563715
        Click image for larger version

Name:	Graphdot.png
Views:	2
Size:	43.5 KB
ID:	1563716

        Comment


        • #5
          I think this refers to a different dataset. On the face of it, it looks like a bug or misfeature in graph dot.

          Comment

          Working...
          X