I am currently trying to create an epicurve and getting really frustrated as I can’t seem to figure out the solution to the problem. Any help would be greatly appreaciated!
I first used the following command to get my epiweek and years from a date:
epiweek onset_date, epiw(epi_week) epiy(epi_year)
The dataset I am working with therefore will have epiweek 1-53 and years 2013, 2014, 2015
Now the problem I have is that I would like to create an epicurve with the x axis “epiweek” to go by 3, however STATA recognizes the epiweek variable as categorical so the xaxis(1(3)53) does not work
If I run the following code, I get epiweek 1-53 correctly with its corresponding year, however there are too many labels on the graph which makes it hard to read, even after I change the size of the graph. Ideally I want them to go by 3
Code 1 – correct representation of data, but too many labels
Code 2- correct forced labels by 3 but corresponding data is incorrect
I first used the following command to get my epiweek and years from a date:
epiweek onset_date, epiw(epi_week) epiy(epi_year)
The dataset I am working with therefore will have epiweek 1-53 and years 2013, 2014, 2015
Now the problem I have is that I would like to create an epicurve with the x axis “epiweek” to go by 3, however STATA recognizes the epiweek variable as categorical so the xaxis(1(3)53) does not work
If I run the following code, I get epiweek 1-53 correctly with its corresponding year, however there are too many labels on the graph which makes it hard to read, even after I change the size of the graph. Ideally I want them to go by 3
Code 1 – correct representation of data, but too many labels
- graph bar (count) Alive Deceased , over(epi_week, label(angle(90) labsize(*0.4))) over(epi_year) stack ytitle ("Number of cases") title ("Number of reported cases of avian influenza A (H7N9) by WHO by week of symptom onset as of x", size(small)) bar(1, blwidth(thin) bcolor(blue)) bar(2, bcolor(red)) legend (label(1 "Alive") label(2 "Deceased"))
- graph display, xsize(10)
Code 2- correct forced labels by 3 but corresponding data is incorrect
- graph bar (count) Alive Deceased , over(epi_week, relabel(1 "1" 2"." 3"." 4 "4" 5"." 6"." 7 "7" 8 "." 9"." 10 "10" 11"." 12"." 13 "13" 14 "." 15 "." 16 "16" 17 "." 18 "." 19 "19" 20 "." 21 "." 22 "22" 23 "." 24 "." 25 "25" 26 "." 27 "." 28 "28" 29 "." 30 "." 31 "31" 32 "." 33 "." 34 "34" 35 "." 36 "." 37 "37" 38 "." 39 "." 40 "40" 41 "." 42 "." 43 "43" 44"." 45 "." 46 "46" 47 "." 48 "." 48 "49" 50 "." 51 "." 52 "52" 53 ".") label(angle(90) labsize(*0.4))) over(epi_year) stack ytitle ("Number of cases") title ("Number of reported cases of avian influenza A (H7N9) by WHO by week of symptom onset as of x", size(small)) bar(1, blwidth(thin) bcolor(blue)) bar(2, bcolor(red)) legend (label(1 "Alive") label(2 "Deceased"))
- graph display, xsize(10)
Comment