Announcement

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

  • histogram colors

    Hi everyone,
    i hope you are all keeping safe. I have a simple question. i am creating a histogram plot for a variable X by gender. when i go to graph editor and change the color of the bars for females for example it does it also fo Males as well.
    any suggestion for a code to solve this simple issue.

    Thanks in advance


    Stata 15.1 Mac

  • #2
    Code:
    sysuse auto, clear
    tw (hist price if foreign, by(foreign, leg(off)) ///
    bcolor(red%70)) (hist price if !foreign, ///
    by(foreign) bcolor(blue%70))
    Res.:

    Click image for larger version

Name:	Graph.png
Views:	1
Size:	20.4 KB
ID:	1557489

    Comment


    • #3
      Many thanks Andrew. Can I show frequency instead of density?

      Comment


      • #4
        Yes, you have the -frequency- option for that

        Code:
        tw (hist price if foreign, by(foreign, leg(off)) ///
        freq bcolor(red%70)) (hist price if !foreign, ///
        by(foreign) freq bcolor(blue%70))

        Comment


        • #5
          Excellent thanks

          Comment

          Working...
          X