Hi everyone,
I would like to create a graph in which, when the two prices are identical, the green colour must prevail over the red colour (i.e. on the graph, when the two values are identical, the green colour must appear).
I enclosed the graph. What I want is that green line should the only one to be viewed from 01 July 2021 to 15 June 2022 (where both lines coincide). Again for approximately on the 1 January 2023 onwards.
In-between, the two lines should be on the graph, as their prices are not the same.
Original graph:
dataex:
I tried something, but it gave me a weird graph:
Attempted graph with above code: 
Could you please tell me how to do this?
Thanks in advance.
Michael
I would like to create a graph in which, when the two prices are identical, the green colour must prevail over the red colour (i.e. on the graph, when the two values are identical, the green colour must appear).
I enclosed the graph. What I want is that green line should the only one to be viewed from 01 July 2021 to 15 June 2022 (where both lines coincide). Again for approximately on the 1 January 2023 onwards.
In-between, the two lines should be on the graph, as their prices are not the same.
Original graph:
dataex:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input double Date float(CompetitivePrice CompetitivePrice_noInter day_Date month_Date year_Date) 22462 110.08 110.08 1 7 2021 22463 110.58 110.58 2 7 2021 22464 102.26 102.26 3 7 2021 22465 88.82 88.82 4 7 2021 22466 106.42 106.42 5 7 2021 22467 105.88 105.88 6 7 2021 22468 107.03 107.03 7 7 2021 22469 101.45 101.45 8 7 2021 22470 104.71 104.71 9 7 2021 22471 107.55 107.55 10 7 2021 end format %td Date
Code:
gen SamePrice = (CompetitivePrice == CompetitivePrice_noInter) # delimit; twoway (line CompetitivePrice Date if SamePrice, lcolor(green)) (line CompetitivePrice Date if !SamePrice, lcolor(red)), legend(cols(1) label(1 "Factual") label(2 "No Intervention Scenario") label(3 "Long Intervention Scenario") position(12) ring(0)) xlabel(, angle(45)) ylabel(0(100)800) tlabel(01jul2021 01oct2021 01jan2022 01apr2022 01jul2022 01oct2022 01jan2023 01apr2023 31jul2023) xtitle("Date") ytitle("€/MWh") plotregion(margin(none)) ; # delimit cr
Could you please tell me how to do this?
Thanks in advance.
Michael
Comment