Announcement

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

  • Having an histogram and two lines on the same graph

    Hi everyone,
    I am a Stata beginner (learning at home for an empirical research university class) . So far, I managed to solve my problems on my own, checking on forums, or asking for help from the TA. But I have now a problem that I do not manage to solve and I am a bit stressed by the time I have to submit my paper.

    My situation is the following: I want to have three graphs in one with a histogram with the number of new case per day, on the same scale and y axis I want to have a line graph about the three days average of these new cases, and finally, on a different y axis, I want to have another line graph showing the reproduction rate (and on this scale I want an horizontal line for the value of 1).

    This is my code :
    twoway line Rsince datesince if country=="Austria", color(blue) yaxis(1) yline(1, lpattern(dash)) xline(`m', lcolor(blue)) ///
    xline(`m14', lcolor(blue) lpattern(dash)) ///
    || line smoothcase datesince if country=="Austria", yaxis (2) ///
    || hist newcase datesince if country=="Austria", yaxis(2)
    When I run my code, it gives me : too many variables specified.

    Did I started right? Do you have any idea how to get the wanted graph.

    I hope I have been clear and understandable enough.

    Thanks

  • #2
    hist allows only one variable name.

    Comment


    • #3
      Thank you Nick!
      Effectively, I had to use bar to obtain what I was looking for.
      Unfortunately, the second line graph does not appear on my graph. I have only the line graph with the R and the bar graph. :/

      Comment


      • #4
        Code error!
        Solved! Thank you!

        Comment

        Working...
        X