Announcement

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

  • Overlaying oneway bar graph to dot plot

    Hello,

    I would like to overlay a dot plot on a bar graph that is not twoway (i used graph bar to plot it) so as to achieve a plot similar to the attached. Kindly assist on how to go about it.

    Thanks
    Noel
    ​​​​​​​
    Attached Files

  • #2
    You need to use graph twoway for this. graph bar can't be combined with any twoway type.

    The same information can be shown using stripplot (SSC), although bars starting at zero are not supported.

    I'd eschew the giraffe graphics (readers expected to turn their heads; truncated labels) and make this horizontal.

    You don't give a data example and you don't explain how the bar heights relate to the data points, so suggesting precise code would be too much like guesswork.

    Comment


    • #3
      The dataset is similar to the one shown on the attachment below. The bars represent the mean coverage over the years of each variable i.e ANC and tt1, while the dots show the mean by province over the years
      Attached Files

      Comment


      • #4
        By "example" (such as we read in #2), ideally, you needed to share data with CODE delimiters or by installing the SSC dataex.

        Please read the FAQ. There, you will find further instruction on how to do this task which, albeit simple, improves the odds of getting helpful advice. Thanks.
        Best regards,

        Marcos

        Comment


        • #5
          Hello everyone,
          Here is my set of dataset. Kindly assist

          clear
          input int year byte province float(meaneverbfed meansba meanyesiron)
          2010 1 97.4521 58.9245 66.15782
          2011 1 97.3343 61.41213 66.470146
          2012 1 96.81127 62.80981 70.24934
          2013 1 98.80833 65.80966 69.168724
          2014 1 98.00909 67.09125 70.869804
          2010 2 97.4521 58.9245 66.15782
          2011 2 97.3343 61.41213 66.470146
          2012 2 96.81127 62.80981 70.24934
          2013 2 98.80833 65.80966 69.168724
          2014 2 98.00909 67.09125 70.869804
          2010 3 97.4521 58.9245 66.15782
          2011 3 97.3343 61.41213 66.470146
          2012 3 96.81127 62.80981 70.24934
          2013 3 98.80833 65.80966 69.168724
          2014 3 98.00909 67.09125 70.869804
          2010 4 97.4521 58.9245 66.15782
          2011 4 97.3343 61.41213 66.470146
          2012 4 96.81127 62.80981 70.24934
          2013 4 98.80833 65.80966 69.168724
          2014 4 98.00909 67.09125 70.869804
          2010 5 97.4521 58.9245 66.15782
          2011 5 97.3343 61.41213 66.470146
          2012 5 96.81127 62.80981 70.24934
          2013 5 98.80833 65.80966 69.168724
          2014 5 98.00909 67.09125 70.869804
          2010 6 97.4521 58.9245 66.15782
          2011 6 97.3343 61.41213 66.470146
          2012 6 96.81127 62.80981 70.24934
          2013 6 98.80833 65.80966 69.168724
          2014 6 98.00909 67.09125 70.869804
          2010 7 97.4521 58.9245 66.15782
          2011 7 97.3343 61.41213 66.470146
          2012 7 96.81127 62.80981 70.24934
          2013 7 98.80833 65.80966 69.168724
          2014 7 98.00909 67.09125 70.869804
          2010 8 97.4521 58.9245 66.15782
          2011 8 97.3343 61.41213 66.470146
          2012 8 96.81127 62.80981 70.24934
          2013 8 98.80833 65.80966 69.168724
          2014 8 98.00909 67.09125 70.869804
          end

          Thanks.

          Comment


          • #6
            So, now we have data, for which thanks, but the only connection with #1 is that (presumably) you still want to draw a graph. I see here 5 distinct means for each variable, one for each year, so province is irrelevant. The bar and dotplot design doesn't seem applicable. Consider

            Code:
            twoway connected  meaneverbfed meanyesiron meansba year, ms(Oh X D) sort legend(pos(3) col(1)) yla(, ang(h))
            You should add intelligible variable labels.

            Click image for larger version

Name:	noel.png
Views:	1
Size:	26.2 KB
ID:	1411010

            Comment


            • #7
              Thank you Nick for the response.

              Comment


              • #8
                Noel, did you post the right data? Based on the graph in post #1 I had expected different values for each province, as in the example below.
                Code:
                foreach var of varlist meaneverbfed meansba meanyesiron {
                  replace `var' = `var' + province
                }
                stripplot meaneverbfed meansba meanyesiron if year==2014, box
                Click image for larger version

Name:	stripplot.png
Views:	1
Size:	12.7 KB
ID:	1411052

                Comment

                Working...
                X