In brief: within each subplot generated by by() using two-way line, I'd like to add possibly more than one vertical line corresponding to a specific date. Here's a sketch of my data structure:
market date y event
1 1/1/01 3 1/3/01
1 1/2/01 2 1/3/01
1 1/3/01 4 1/3/01
1 1/4/01 3 1/3/01
1 1/5/01 5 1/3/01
2 1/1/01 6 1/4/01
2 1/2/01 7 1/4/01
2 1/3/01 7 1/4/01
2 1/4/01 3 1/4/01
2 1/5/01 3 1/4/01
To create my basic graph, I use:
twoway (line y date), by(market)
My question: for each subplot in the resulting figure, how do I add a vertical line at "1/3/01" in the first subplot and at "1/4/01" in the second subplot? However, instead of having two distinct markets, I have a few hundred. My plan is to split the plotting statement across groups of markets, but I still need some automated way to add vertical lines (rather than just hardcoding the values in xline() myself for each market).
I'm open to reconfiguring the data as necessary. If this has an easy solution, one wrinkle I'll mention is that I actually have "event1" and "event2", and so would eventually like to add multiple vertical lines to each subplot, preferably using different colors. I'm relatively new to graphing in Stata so figured this could be left to later...
Many thanks and happy holidays,
Brett
market date y event
1 1/1/01 3 1/3/01
1 1/2/01 2 1/3/01
1 1/3/01 4 1/3/01
1 1/4/01 3 1/3/01
1 1/5/01 5 1/3/01
2 1/1/01 6 1/4/01
2 1/2/01 7 1/4/01
2 1/3/01 7 1/4/01
2 1/4/01 3 1/4/01
2 1/5/01 3 1/4/01
To create my basic graph, I use:
twoway (line y date), by(market)
My question: for each subplot in the resulting figure, how do I add a vertical line at "1/3/01" in the first subplot and at "1/4/01" in the second subplot? However, instead of having two distinct markets, I have a few hundred. My plan is to split the plotting statement across groups of markets, but I still need some automated way to add vertical lines (rather than just hardcoding the values in xline() myself for each market).
I'm open to reconfiguring the data as necessary. If this has an easy solution, one wrinkle I'll mention is that I actually have "event1" and "event2", and so would eventually like to add multiple vertical lines to each subplot, preferably using different colors. I'm relatively new to graphing in Stata so figured this could be left to later...
Many thanks and happy holidays,
Brett
Comment