Announcement

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

  • how to ask stata to round the labels in a bar graph?

    Hi ,

    I am using the following code to make a graph. but the decimals in the graph are annoying. is there a way to round the decimals in the label to the closest number?

    #delimit ;
    graph bar (sum) v012 ,over(province) blabel(total) name(mstril,replace) ylabel(, angle(horizontal)) bargap(10)
    legend(label(1 "USAID factors") label(2 "SNIS factors"))
    ytitle("CYP")
    title("Male Sterilization CYP by quarter")
    subtitle(" Apr 2013- Mar 2015")
    note("Source: ASSP service statistices") ;
    #delimit c

    Thanks


  • #2
    Code:
    blabel(total, format(%9.0f))

    Comment


    • #3
      "decimals in the graph": where? I guess you mean on the y axis. Or perhaps in the bar labels.

      It could well be that graph bar is just copying what you have specified previously as the display format for v012.

      "closest number" is a number-theoretic enigma; I guess you mean some suitable close integer.

      Spell out a suitable format in the argument to ylabel(): see document of format() linked to from help axis label options. Or, if relevant, do the same with blabel().

      If this doesn't help enough, show us the graph and/or show us the results of

      Code:
       
      describe v012 
      tabstat v012, s(sum) by(province)

      Comment


      • #4
        thanks David and Nick!

        Sorry Nick for bad wording. yes I meant closest integer. the following worked very well. I needed to change format of labeling.
        blabel(total, format(%9.0f)) ) worked very well.

        Comment


        • #5
          I am Collins Mukhala. I am working on a data set with multiple responses and want to graph using mrgraph and label the bars with percent results. I don't know how labeling bars is done using mrgaph. Can anyone who know help me. One of the graphs that I have plotted with mrgraph is here:

          [IMG]file:///C:\Users\ADMINI~1\AppData\Local\Temp\msohtmlclip1\ 01\clip_image002.png[/IMG]

          Comment

          Working...
          X