Announcement

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

  • Simple Bar Graph - Having Trouble

    HI There,

    I am looking to put together a simple bar graph that gives me the count of the number times an "information source" was used by a farmer. The data is below:

    Code:
    informationsource    count    percent
    Producer Associations    51    79.69%
    Other Farmers    37    57.81%
    Agricultural Input Suppliers    30    46.88%
    3rd Party Consultants    19    29.69%
    Government Organizations    35    54.69%
    Internet    54    84.38%
    Universities    25    39.06%
    Technology Companies    25    39.06%
    Family and Friends    25    39.06%
    None    2    3.13%
    Other    2    3.13%
    Social Media    23    35.94%
    Where on my y-axis I have the count or the percentage (it doesn't really matter - they will look the same) of each information source and on my x-axis is the name of the information source itself. I have attached a picture below of what the graph looks like in excel:

    Click image for larger version

Name:	Picture1.png
Views:	1
Size:	83.2 KB
ID:	1492519


    I have used bar graph and bar graph count but I can't seem to understand how to graph a chart like the one above. I have used the following codes:

    Code:
    graph bar (count), over(count)
    
    graph bar, over(count)
    But something is clearly missing and I haven't come across a simple workaround. Can someone advise? Thanks!

  • #2
    Please use dataex to present data examples in the future.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str99 informationsource float(count percent)
    "Producer Associations"        51 79.69
    "Other Farmers"                37 57.81
    "Agricultural Input Suppliers" 30 46.88
    "3rd Party Consultants"        19 29.69
    "Government Organizations"     35 54.69
    "Internet"                     54 84.38
    "Universities"                 25 39.06
    "Technology Companies"         25 39.06
    "Family and Friends"           25 39.06
    "None"                          2  3.13
    "Other"                         2  3.13
    "Social Media"                 23 35.94
    end
    
    graph hbar percent, over(information, sort(1)) bar(1, color(none)) scheme(s1color) ///
    title("Information Sources used by Ontario Farmers", size(medium))  ///
    ytitle("Percent") blabel(total) ylabel(0 (10) 90)
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	51.1 KB
ID:	1492573

    Comment

    Working...
    X