Announcement

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

  • How to draw a three dimensional line graph with panel data

    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?

  • #2
    Stata doesn't seem to have and predefined commands to make 3D graphs. There is a user contributed command called -graph3d- which might be of interest.

    See the announcement of the command on this forum: http://www.statalist.org/forums/foru...table-3d-plots

    Comment


    • #3
      Various confusions here. I can't see that you really are asking for a 3D graph any way. You just have two time series and two graphical dimensions, response or outcome and time.
      Note that with

      Code:
      twoway line meanrecycle year if tag, addplot(line meanincome year if tag), sort
      the problem is one comma too many; there is nothing wrong syntactically with the addplot() call otherwise. This would be legal:

      Code:
      twoway line meanrecycle year if tag, addplot(line meanincome year if tag) sort
      You can plot two series together and this is simpler and more direct than any code you tried:

      Code:
      line meanrecycle meanincome year if tag, sort
      If that produces a mess, then consider

      Code:
      preserve 
      keep if tag 
      line meanrecycle meanincome year, sort 
      restore
      The problem is likely to be substantive, very different units and magnitudes, so that the series appear very separated.

      There are various solutions, not least dividing the larger numbers by some convenient constant. It's partly a matter of taste but my own preference is just for juxtaposed panels. See http://www.statalist.org/forums/foru...le-time-series for discussion.

      You could give your summarized data for others to experiment.

      Please do read and act on FAQ Advice http://www.statalist.org/forums/help#stata for showing code and example data,

      Comment

      Working...
      X