Announcement

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

  • adding a horizontal line to a graph bar

    Would anyone know how to add a horizontal line to a graph bar? My y-axis is a % and I would like to add a horizontal line at 15%.
    My graph bar command without the horizontal line I would like to add is as follow:

    Code:
    graph bar (mean) d_pc, over(diasem) ytitle("") subtitle("% de Partos Cesáreos por Dia da Semana: 2006-2013")

  • #2
    Just add an extra option

    Code:
    yline(15)
    This is documented: in the help for graph bar, click on axis_options.

    Comment


    • #3
      Thank you, Nick.

      I did not find an option to bring the horizontal line to the front. The default is the horizontal in the back of the bars. Would you know how to change that?



      Comment


      • #4
        That sounds like a feature to me. To get other behaviour, I think you would need to recast using twoway as in this case:

        Code:
        sysuse auto, clear
        
        * 1 
        graph bar (mean) mpg, over(rep78) yli(23)
        
        collapse mpg, by(rep78)
        
        * 2 
        twoway bar mpg rep78, base(0) barw(0.6) || function y = 23, ra(0.7 5.3) ///
        yla(0(5)40) legend(off) ytitle(Mean miles per gallon) xtitle(`: var label rep78')

        Comment


        • #5
          How do i shade an area to the right after drawing an.... xline(20, lwidth(3)).... please advise

          Comment


          • #6
            How can i do a shading like what i have attached in stata!!! any help please ...
            Attached Files

            Comment


            • #7
              #6 is poorly placed, as the question has nothing to do with the title thread. But see these suggestions thrown up by typing in Stata.

              Code:
              search shading


              Blog . . . . . . . . . . . . Adding recession shading to time-series graphs
              . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D. Schenck
              2/20 http://blog.stata.com/2020/02/13/add...ssion-shading-
              to-time-series-graphs/

              SJ-16-3 gr0067 . Speaking Stata: Shading zones on time series and other plots
              . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox
              Q3/16 SJ 16(3):805--812 (no commands)
              discusses background shading of time series and other plots



              Comment

              Working...
              X