Hello,
I am working on a panel data including information about 67 counties in Florida from 1995-2014. I want to draw a three dimensional line graph. I mean I want to make my X-axis as year (group), y_axis as mean county recycling rate for 67 counties in each year, and graphed line is mean county income for 67 counties in each year. Basically, I want to see the correlation between income and county recycling rate in each year.
I am quiet confused with the command of addplot and collapse.
First, when I write conmmand
>egen meanrecycle=mean(recycle), by (year)
>egen tag=tag(year)
>twoway line meanrecycle year if tag, sort
>egen meanincome=mean(income), by (year)
>egen tag=tag(year)
>twoway line meanincome year if tag, sort
>twoway line meanrecycle year if tag, addplot(line meanincome year if tag), sort
Stata doesn't allow me to use addplot.
I also tried
>line meanrecycle year if tag|| line meanincome year if tag, sort
But the graph looks really weird. since the shape of two lines when putting them into one graph are different from what they are like when I plot them separately.
Second, since if I simply use addplot to add two line plots into one graph, the Y axis for these two plots are different. Does it mean I need to use collapse?
I searched for syntax, but nothing really fit my question. Does anyone help me to solve my question?
I am working on a panel data including information about 67 counties in Florida from 1995-2014. I want to draw a three dimensional line graph. I mean I want to make my X-axis as year (group), y_axis as mean county recycling rate for 67 counties in each year, and graphed line is mean county income for 67 counties in each year. Basically, I want to see the correlation between income and county recycling rate in each year.
I am quiet confused with the command of addplot and collapse.
First, when I write conmmand
>egen meanrecycle=mean(recycle), by (year)
>egen tag=tag(year)
>twoway line meanrecycle year if tag, sort
>egen meanincome=mean(income), by (year)
>egen tag=tag(year)
>twoway line meanincome year if tag, sort
>twoway line meanrecycle year if tag, addplot(line meanincome year if tag), sort
Stata doesn't allow me to use addplot.
I also tried
>line meanrecycle year if tag|| line meanincome year if tag, sort
But the graph looks really weird. since the shape of two lines when putting them into one graph are different from what they are like when I plot them separately.
Second, since if I simply use addplot to add two line plots into one graph, the Y axis for these two plots are different. Does it mean I need to use collapse?
I searched for syntax, but nothing really fit my question. Does anyone help me to solve my question?
Comment