Announcement

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

  • Graph bar, change the bar color

    Hi Stata users,
    I am using below command for creating bar chart.

    Code:
    webuse studentsurvey, clear
    graph bar (count), over(female) by(dept)
    I would be happy if someone guide me how to change the bar color. I want the color of first bar to be red and the second one to be blue in every sub-chart.






  • #2
    You may just add the option - asyvars - for that matter.
    Best regards,

    Marcos

    Comment


    • #3
      Fiddling with the commands, you may also try something like:

      Code:
      graph bar, over(female) ascategory asyvars bar(1, fcolor(red)) bar(2, fcolor(blue)) by(dept) bargap(5)

      If you wish to get the default red and blue colors you're used to see in Stata's bar graphs, just type:

      Code:
      graph bar, over(female) ascategory asyvars bar(1, fcolor(maroon)) bar(2, fcolor(navy)) by(dept) bargap(5)
      Hopefully that helps.
      Last edited by Marcos Almeida; 28 Aug 2018, 08:10.
      Best regards,

      Marcos

      Comment


      • #4
        Thank you a lot Marcos,
        It works perfectly.

        Bests,
        Fahim

        Comment


        • #5
          Originally posted by Marcos Almeida View Post
          Fiddling with the commands, you may also try something like:

          Code:
          graph bar, over(female) ascategory asyvars bar(1, fcolor(red)) bar(2, fcolor(blue)) by(dept) bargap(5)

          If you wish to get the default red and blue colors you're used to see in Stata's bar graphs, just type:

          Code:
          graph bar, over(female) ascategory asyvars bar(1, fcolor(maroon)) bar(2, fcolor(navy)) by(dept) bargap(5)
          Hopefully that helps.
          Very helpful! Thank you very much!

          Comment


          • #6
            Ahmed Adib Great that it was helpful.
            Best regards,

            Marcos

            Comment

            Working...
            X