Announcement

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

  • Consult the Name of the Color and How I Can Paint it on the Bar Chart in Stata.



    Hello,
    The color of the fourth bar is not pure yellow, and I really don't know what the real name of this color is.
    Also, the color of the 3rd bar is not pure green.
    Can someone tell me the truth?
    Thank you!


    clear
    input byte race outcome minor medium severe
    1 1 .7048 .5184 .3047
    2 1 .7004 .4876 .1779
    3 1 .7232 .5578 .3354
    4 1 .7284 .5508 .2053
    1 2 .2429 .3565 .4077
    2 2 .2461 .3705 .3543
    3 2 .2297 .3363 .4086
    4 2 .2258 .3401 .3744
    1 3 .0522 .1251 .2875
    2 3 .0535 .1419 .4687
    3 3 .0471 .1059 .2561
    4 3 .0457 .1091 .4204
    end

    // Set graph style
    grstyle init

    // Add race labels
    label define race_label 1 ///
    "Black" 2 "Hispanic" ///
    3 "White" 4 "Other"
    label values race race_label

    // Add outcome labels
    label define outcome_label 1 ///
    "Low Disciplinary Action" ///
    2 "Medium Disciplinary Action" ///
    3 "High Disciplinary Action"
    label values outcome outcome_label


    g outcomeracee = race if outcome == 1
    replace outcomeracee = race+5 if outcome == 2
    replace outcomeracee = race+10 if outcome == 3
    sort outcomeracee
    list outcomeracee outcome race, sepby(outcome)

    set scheme s1color
    // Medium Infractions Graph with symbols that show statistical significance.
    tw (bar medium outcomeracee if race==1, bcolor(blue)) ///
    (bar medium outcomeracee if race==2, bcolor(red)) ///
    (bar medium outcomeracee if race==3, bcolor(green)) ///
    (bar medium outcomeracee if race==4, bcolor(yellow)), ///
    legend(row(4) position(right) ///
    order(1 "Hispanic" 2 "Black" 3 "White" 4 "Other")) ///
    legend(region(lstyle(none))) ///
    xlabel(0(5) 15) ylabel(0(0.2) 0.8) ///
    xlabel( 3 "Low" 8 "Middle" 13 "High", noticks) ///
    ytitle("Predicted Probability of Disciplinary Action") ///
    title("Minor Infractions") xtitle("") ///
    plotregion(style(none))
    Click image for larger version

Name:	123.JPG
Views:	2
Size:	144.0 KB
ID:	1715126










    Last edited by smith Jason; 26 May 2023, 17:20.

  • #2
    I really cannot get the colors of the attached snapshot with the Stata code above.



    Comment


    • #3
      If I remove the line -grstyle init-, I see a graph with pure yellow, so I can't really reproduce your problem. You can find all of the named colours as well as how to specify alternative colours in -help colorstyle-. One of the options is to specify RGB decimal valued (0-255) colours as "R G B".

      Comment


      • #4
        What I want is to determine the name of the colors in the attached snapshot. However, I cannot find them.
        Thank you for your help.




        Comment


        • #5
          You can generate the list of the colors based on your reference figure.

          I typically follow these steps:

          1. Go to imagecolorpicker.com (or any other free platform).
          2. Upload your reference figure.
          3. Click on the colors you have interest in.
          4. Get the RGB code. Example :rgba(1,191,127,255)
          5. Instead of writing bcolor(green), you can specify bcolor("1 191 127")

          I typically use a high-res figure to get the exact colors.


          Code:
          clear
          input byte race outcome minor medium severe
          1 1 .7048 .5184 .3047
          2 1 .7004 .4876 .1779
          3 1 .7232 .5578 .3354
          4 1 .7284 .5508 .2053
          1 2 .2429 .3565 .4077
          2 2 .2461 .3705 .3543
          3 2 .2297 .3363 .4086
          4 2 .2258 .3401 .3744
          1 3 .0522 .1251 .2875
          2 3 .0535 .1419 .4687
          3 3 .0471 .1059 .2561
          4 3 .0457 .1091 .4204
          end
          
          
          
          // Add race labels
          label define race_label 1 ///
          "Black" 2 "Hispanic" ///
          3 "White" 4 "Other"
          label values race race_label
          
          // Add outcome labels
          label define outcome_label 1 ///
          "Low Disciplinary Action" ///
          2 "Medium Disciplinary Action" ///
          3 "High Disciplinary Action"
          label values outcome outcome_label
          
          
          g outcomeracee = race if outcome == 1
          replace outcomeracee = race+5 if outcome == 2
          replace outcomeracee = race+10 if outcome == 3
          sort outcomeracee
          list outcomeracee outcome race, sepby(outcome)
          
          set scheme s1color
          // Medium Infractions Graph with symbols that show statistical significance.
          tw (bar medium outcomeracee if race==1, bcolor("27 133 255")) ///
          (bar medium outcomeracee if race==2, bcolor("213 17 89")) ///
          (bar medium outcomeracee if race==3, bcolor("1 191 127")) ///
          (bar medium outcomeracee if race==4, bcolor("255 212 1")), ///
          legend(row(4) position(right) ///
          order(1 "Hispanic" 2 "Black" 3 "White" 4 "Other")) ///
          legend(region(lstyle(none))) ///
          xlabel(0(5) 15) ylabel(0(0.2) 0.8) ///
          xlabel( 3 "Low" 8 "Middle" 13 "High", noticks) ///
          ytitle("Predicted Probability of Disciplinary Action") ///
          title("Minor Infractions") xtitle("") ///
          plotregion(style(none))
          Last edited by Tiago Pereira; 26 May 2023, 20:28.

          Comment


          • #6
            Thank you!




            Comment

            Working...
            X