Announcement

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

  • Is not a two-way plot type

    Hello,

    I keep getting the error not a twoway plot type. Was wondering if anyone had any suggestions.

    levelsof county, local(cty)
    levelsof disease, local(dis)
    foreach c of local cty{
    foreach d of local dis{
    twoway (bar cases year if county=="`c'" & disease=="`d'", yaxis(2) ///
    yscale(range(0,2500) axis(2)) ///
    ytick(0(500)2500, axis(2)) ///
    ylabel(0(500)2500, axis(2))) ///
    (line rate1 year if county=="`c'" & disease=="`d'", sort yaxis(1) ///
    yscale(range(0,35) axis(1)) ///
    ytick(0(5)35, axis(1)) ///
    ylabel(0(5)35, axis(1))) ///
    (rcap lower_95__ci upper_95__ci year if county=="`c'" & disease=="`d'", yaxis(1) ///
    yscale(range(0,35) axis(1)) ///
    ytick(0(5)35, axis(1)) ///
    ylabel(0(5)35, axis(1))), ///
    scheme(sj) ///
    legend(label(1 "Cases") label(2 "Rate") label(3 "95%CI") row(1)) ///
    ytitle("Rate, per 100,000 population", axis(1)) ///
    title("`d' in `c', 2001-2019") ///
    note("Data source: kaggle.com/zayanmakar/infectious-diseases-county-year-and-sex")///
    graph export "Output/top5.png", replace ///
    putexcel set "Output/GraphFile.xlsx", modify ///
    putexcel B`3' = image(Output/top5.png) ///
    }
    }
    Last edited by Alec Wilcox; 23 Dec 2021, 18:00.

  • #2
    What exactly does Stata say "is not a twoway plot type"? They must give a word or a character, no?

    Comment


    • #3
      The three slashes (///) indicate to Stata that the next line is a continuation of the current line. Your use of the three slashes at the end of:
      Code:
      note("Data source: kaggle.com/zayanmakar/infectious-diseases-county-year-and-sex")///
      indicates that the next line:
      Code:
      graph export "Output/top5.png", replace ///
      is a continuation of the graph command (and by extension that both putexcel lines, which also have three slashes at the end, are part of the graph command).

      The solution to your problem is to remove the three slashes (///) from the end of the last four lines of code.
      Last edited by Ali Atia; 23 Dec 2021, 18:33.

      Comment

      Working...
      X