Announcement

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

  • How to remove x axis labels in bar graphs

    Hi
    I need to make a bar graph in Stata with over 600 categories. Given the large number of categories, I want to remove the category names or x labels and instead add xtitle describing the categories in one line. From what I found in the 'graph bar' stata documentation, bar graphs does not have any x-axis options. Thus, standard codes such as xlabel(, nolabels) does not work.
    Would be very grateful if you could suggest an alternative on how I could carry out the desired task and make my graphs readable and communicative.

    Thank you!

  • #2
    Code:
    graph bar var1, over(var2, lab(nolab))

    Comment


    • #3
      Thank you. It worked! Could you suggest a way by which I can add title to the xaxis.

      Comment


      • #4
        Code:
        graph bar var1, over(var2, lab(nolab)) b1title("my title")
        All this is documented at

        Code:
        help graph bar

        Comment


        • #5
          Thanks a lot for your guidance. The title also works now.
          Unfortunately I was unable to find these options under the relevant documentation "https://www.stata.com/manuals13/g-2graphbar.pdf". Please let me know if any other source(s) that could be helpful, in case I need to explore other graph bar options. Thank you!

          Comment


          • #6
            The PDF has clickable links, e.g., cat axis label options on page 3 of the following:

            https://www.stata.com/manuals13/g-2g...df#g-2graphbar

            You can also search the forum, but you are always free to post here if you can't find what you want. Hopefully, someone will have an answer.

            Comment


            • #7
              It sounds as if you have 600 or so values and want to show their distribution. The associated names may be of some interest but you don't have space to show them.

              I'd start with quantile in that case.

              Comment


              • #8
                Thank you Dr. Cox

                Comment


                • #9
                  Adding to Abhilasha's question, how do I have a common y-label instead of suppressing all.

                  Comment


                  • #10

                    Adding to Abhilasha's question, how do I have a common y-label instead of suppressing all. I want the race to be displayed only in the first graph.

                    use http://www.stata-press.com/data/r14/nlswork

                    graph hbar tenure hours wks_work if age < 16, ///
                    over(race, label(labstyle()) ) ///
                    by(age, style(combine) row(1) norescale edgelabel iylabel noiytitle iytick noiyaxes) ///
                    legend(label (1 "tenure") label (2 "hours") label (3 "wks_work") row(1)) ///
                    ysize(2) name(a, replace)

                    Click image for larger version

Name:	aa.png
Views:	4
Size:	73.0 KB
ID:	1641822

                    Comment


                    • #11
                      #10 is a duplicate post. See https://www.statalist.org/forums/for...-x-axis-labels for comment.

                      Comment


                      • #12
                        bibha dhungel Why not just create the bar graphs separately for each value of age, instead of creating the graphs by(age). This way, you can supress the axis labels/lines as required and then combine the graphs in the desired format using - graph combine - and specifying e.g. rows(1). If you want a single legend, use the excellent - grc1leg2 - available from SSC.
                        Finally, if you have lots of age values to graph, you can do so in a - forvalues - loop.

                        Comment

                        Working...
                        X