Announcement

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

  • Using -addlabels- option with -histogram-

    I am using the addlabels option with histogram. This adds height labels to ALL the bars. Instead, I want to add height labels only to bars of extreme values, ie if the variable I am plotting is above a threshold.
    1. Is this possible?
    2. Is it possible to reduce the font of these labels or change the color of their font?
    I have gone through some documentation here but haven't been able to do these edits. I am using Stata 15.

    Code:
    local var14 x y
    foreach v of var `var14' {
        #d ;
        histogram `v', frequency addlabels bin(50) color(red%30) lwidth(thin) ti("`v'")
        xmtick(##10) xlabel(#10, angle(90) nogrid labsize(small)) ylabel(, labsize(small) nogrid)
        xline(100000, lpattern(dash) lcolor(black))
        xline(0, lpattern(dash) lcolor(black))
        scheme(s2mono) yscale(noline) plotregion(lcolor(black) lwidth(thin));
        #d cr
        graph export "`v'_test.png", replace
    }
    Last edited by Mihir Sharma; 08 May 2018, 13:05. Reason: histogram

  • #2
    Here are a few small tricks:

    Code:
    sysuse auto, clear
    set scheme s1color 
    twoway__histogram_gen mpg, gen(Frequency MPG) discrete width(2) freq 
    twoway bar Frequency MPG, barw(2) bfcolor(none) blcolor(black) xtitle(Miles per gallon) legend(off) || ///
    scatter Frequency MPG if Freq > 12, ms(none) mla(Freq) mlabpos(12) mlabc(black) mlabsize(*1.5)  yla(, ang(h))

    Comment

    Working...
    X