Announcement

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

  • Bar Graphs

    Hello,

    I need a bar graph, Horizontal bar. Using Categories function, tax 0 is 1st group, taxp5 2nd and tax 1 is 3rd. each group should have 2 bars, 1st is 1A & 2A. 2nd bar has 1B & 2B. Could someone please help how to do it?

    Click image for larger version

Name:	1.png
Views:	1
Size:	42.0 KB
ID:	1530737

    It should be something like this. Two bars not four

    I am grateful for any help!
    Click image for larger version

Name:	2.png
Views:	2
Size:	45.3 KB
ID:	1530738

  • #2
    Osama,

    How about something like this:

    Code:
    graph bar tax0 tax5 tax1, over(condition)
    Best,
    Alan

    Comment


    • #3
      Thank you Alan. It is not what I need. I would like to have 3 groups, horizontal, not vertical, and conditions (5A, 5B, 5C, 5D) should not be taken into consideration. I need just two conditions, the mean of 1A+2A and the mean of 1B + 2B

      Comment


      • #4
        Please read and act on https://www.statalist.org/forums/help#stata We need

        * a data example using dataex

        * the graph syntax you tried

        * the resulting graph so far

        * above all, unambiguous specification of what you want

        The example graph is hard, indeed for me impossible, to decode. No labels or titles! Is it supposed to be a graph of means -- which are central to the summarize results you show -- or a graph of counts or frequencies?

        Comment


        • #5
          Dear Nick,

          thanks a lot for your answer.

          This is a data example using
          Code:
          dataex
          I hope I do it in the correct way

          Code:
          * Example generated by -dataex-. To install: ssc install dataex
          clear
          input byte tasks_completed str2 condition byte assigned_payment float(condition_1A condition_1B condition_2A condition_2B condition_5A condition_5B condition_5C condition_5D tax0 taxp5 tax1)
          50 "1A" 4 1 0 0 0 0 0 0 0 1 0 0
          50 "1A" 4 1 0 0 0 0 0 0 0 1 0 0
          50 "1A" 4 1 0 0 0 0 0 0 0 1 0 0
          50 "1A" 4 1 0 0 0 0 0 0 0 1 0 0
          50 "1A" 4 1 0 0 0 0 0 0 0 1 0 0
          50 "1A" 4 1 0 0 0 0 0 0 0 1 0 0
          50 "1A" 4 1 0 0 0 0 0 0 0 1 0 0
          50 "1A" 4 1 0 0 0 0 0 0 0 1 0 0
          50 "1A" 4 1 0 0 0 0 0 0 0 1 0 0
          50 "1A" 4 1 0 0 0 0 0 0 0 0 1 0
          50 "1A" 4 1 0 0 0 0 0 0 0 1 0 0
          50 "1A" 4 1 0 0 0 0 0 0 0 1 0 0
          50 "1A" 4 1 0 0 0 0 0 0 0 1 0 0
          50 "1A" 4 1 0 0 0 0 0 0 0 1 0 0
          50 "1A" 4 1 0 0 0 0 0 0 0 1 0 0
          50 "1A" 4 1 0 0 0 0 0 0 0 1 0 0
          50 "1A" 4 1 0 0 0 0 0 0 0 1 0 0
          50 "1A" 4 1 0 0 0 0 0 0 0 0 1 0
          50 "1A" 4 1 0 0 0 0 0 0 0 1 0 0
          50 "1A" 4 1 0 0 0 0 0 0 0 1 0 0
          50 "1A" 4 1 0 0 0 0 0 0 0 0 1 0
          50 "1A" 4 1 0 0 0 0 0 0 0 1 0 0
          50 "1A" 4 1 0 0 0 0 0 0 0 1 0 0
          50 "1A" 4 1 0 0 0 0 0 0 0 1 0 0
          50 "1A" 4 1 0 0 0 0 0 0 0 1 0 0
          I tried this syntax

          Code:
          graph hbar (mean) condition_1A condition_2A (mean) condition_1B condition_2B, over(ta > x0) over(taxp5)
          and got the attached graph.

          As I am a student and in the learning process, I am trying to replicate the graph done by a researcher (who provides me with the data). The provided graph is also attached. (In grey)

          In the Original graph, we have on the y-axis three groups. One is the for people voted for no taxes (tax0), the second group is for people voted for 0.5$ tax (taxp5), and the last group people voted for 1$ tax (tax1). Also, we have 4 bars. But I need just two, which should be the mean of (condition1A + condition 2A) & the 2nd bar should be the mean of (condition1B + condition2B)

          Thanks a lot for your help!
          Attached Files
          Last edited by Osama Farroukh; 05 Jan 2020, 07:50.

          Comment


          • #6
            "Not sure if I post the graphs as described in the FAQ, If not please advice me"

            Comment


            • #7
              This may help:

              Code:
              gen A = condition_1A +  condition_2A
              gen B = condition_1B +  condition_2B  
              graph hbar (mean) A B, over(tax0) over(taxp5)
              Last edited by Nick Cox; 06 Jan 2020, 03:07.

              Comment

              Working...
              X