Announcement

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

  • start() option for histogram causing diagonal line

    Hi,

    I'm making overlapping histograms and I need the start(0) option for empty (no color) dash bins but it makes a diagonal line across the graph as you can see below. I tested this with the default STATA scheme (s2color) also and it makes no difference. A solution to this would be most appreciated.

    Thanks.

    Code:
    clear all
    
    
    input days dummy
    10 0
    25 0
    10 1
    10 1
    25 1
    30 1
    30 1
    55 0
    55 0
    55 0
    70 1
    70 1
    70 1
    120 1
    120 1
    end
    
    set scheme s2color
    
    twoway histogram days if dummy==1, fcolor(none) lcolor(black%50) lpattern(dash) width(50) start(0) || histogram days if dummy==0, fcolor(ply3%50) lcolor(ply3%50) start(0) width(50) ylabel(0(0.002)0.013) legend(order(1 "Equals 1" 2 "Equals 0"))
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	80.4 KB
ID:	1653041

  • #2
    Somehow the weirdness is a side-effect of lpattern(dash) but I don't have an explanation.

    Comment


    • #3
      You're right. Without lpattern() there is no issue but the black outlined bins become less visible without a pattern. Hopefully this will be fixed in the future.

      Comment


      • #4
        I would drop transparency for the bars and fill the concealed lines using tw scatteri


        Code:
        * Example generated by -dataex-. For more info, type help dataex
        clear
        input float(days dummy)
         10 0
         25 0
         10 1
         10 1
         25 1
         30 1
         30 1
         55 0
         55 0
         55 0
         70 1
         70 1
         70 1
        120 1
        120 1
        end
        
        twoway histogram days if dummy==1, sort fcolor(none) lcolor(black%50) ///
        lpattern(dash) width(50) start(0) || histogram days if dummy==0, sort fcolor(ply3*.3) ///
        lcolor(ply3%50) start(0) width(50) ylabel(0(0.002)0.013) ///
        legend(order(1 "Equals 1" 2 "Equals 0")) || scatteri 0.006 50 0.006 100, recast(line) ///
        lcolor(ply3%50) lpattern(dash) plotregion(margin(zero))
        Click image for larger version

Name:	Graph.png
Views:	1
Size:	34.6 KB
ID:	1653055

        Comment


        • #5
          Thanks for this solution Andrew! Unfortunately I have many figures to make and cannot put in the effort of making all of those bins manually. Really hope STATA will get to the bottom of this some day.

          Comment

          Working...
          X