Search code examples
stata

Second y axis for panel data with xtline


I have panel data for spreads and illiquidity for a number of countries. Now I would like to draw for each country separately a graph with time on the x-axis and the spreads and illiqudity on two different y-axes.

xtline spreads illiquidity, i(Country) t(quarter)

above is the command which draws me the graphs with ONE y-axis but I do not get around how to implement the second y-axis.

The general twoway syntax, such as:

twoway (xtline spreads, ...) (xtline illiquidity, ... yaxis(2)) 

does not apply to xtline.


Solution

  • You didn't provide data that we can replicate with. Here's a toy example using the addplot option. See if it does what you asked for.

    sysuse xtline1, clear
    gen new_y=runiform() // second y
    xtset person day
    xtline calories, addplot(line new_y day, yaxis(2))