Nick Cox Hello there M. Cox;
Sorry if this post took more time and explanation than it should have to, but I keep getting back to it once I get problems with such elaborate time graphs, your explanation is helpful.
I'm working with this data currently on a 13.1 Stata version:
This data shows the evolution on a stock market index by month, starting from 2015 until 2025.
I'm using this code that's inspired by your suggestions:
gen mdate = monthly(substr(Month, 1, 7), "YM")
local tickpos = ym(2015, 12) + 0.5
local ticks `tickpos'
forval y = 2015/2025 {
local labelpos = `tickpos' + 6
local labels `labels' `labelpos' "`y'"
local tickpos = ym(`y', 12) + 0.5
local ticks `ticks' `tickpos'
}
label var Value " Value "
line Value mdate, lc(red blue) yla(, ang(h)) ytitle(%, orient(horiz)) xla(`labels', noticks) xticks(`ticks', tlength(*3)) xtitle("") legend(ring(0) pos(11) col(1)) xsc(r(. `=ym(2025, 6)')) xli(`ticks', lc(gs12))
Yet, I do get an empty graph without the line of the index that I'm studying.
Any help with this code please?
With many thanks!
Sorry if this post took more time and explanation than it should have to, but I keep getting back to it once I get problems with such elaborate time graphs, your explanation is helpful.
I'm working with this data currently on a 13.1 Stata version:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str10 Month float Value "01/30/2015" 1994.99 "02/27/2015" 2104.5 "03/31/2015" 2067.89 "04/30/2015" 2085.51 "05/29/2015" 2107.39 "06/30/2015" 2063.11 "07/31/2015" 2103.84 "08/31/2015" 1972.18 "09/30/2015" 1920.03 "10/30/2015" 2079.36 "11/30/2015" 2080.41 "12/31/2015" 2043.94 "01/29/2016" 1940.24 "02/29/2016" 1932.23 "03/31/2016" 2059.74 "04/29/2016" 2065.3 "05/31/2016" 2096.96 "06/30/2016" 2098.86 "07/29/2016" 2173.6 "08/31/2016" 2170.95 "09/30/2016" 2168.27 "10/31/2016" 2126.15 "11/30/2016" 2198.81 "12/30/2016" 2238.83 "01/31/2017" 2278.87 "02/28/2017" 2363.64 "03/31/2017" 2362.72 "04/28/2017" 2384.2 "05/31/2017" 2411.8 "06/30/2017" 2423.41 "07/31/2017" 2470.3 "08/31/2017" 2471.65 "09/29/2017" 2519.36 "10/31/2017" 2575.26 "11/30/2017" 2647.58 "12/29/2017" 2673.61 "01/31/2018" 2823.81 "02/28/2018" 2713.83 "03/29/2018" 2640.87 "04/30/2018" 2648.05 "05/31/2018" 2705.27 "06/29/2018" 2718.37 "07/31/2018" 2816.29 "08/31/2018" 2901.52 "09/28/2018" 2913.98 "10/31/2018" 2711.74 "11/30/2018" 2760.17 "12/31/2018" 2506.85 "01/31/2019" 2704.1 "02/28/2019" 2784.49 "03/29/2019" 2834.4 "04/30/2019" 2945.83 "05/31/2019" 2752.06 "06/28/2019" 2941.76 "07/31/2019" 2980.38 "08/30/2019" 2926.46 "09/30/2019" 2976.74 "10/31/2019" 3037.56 "11/29/2019" 3140.98 "12/31/2019" 3230.78 "01/31/2020" 3225.52 "02/28/2020" 2954.22 "03/31/2020" 2584.59 "04/30/2020" 2912.43 "05/29/2020" 3044.31 "06/30/2020" 3100.29 "07/31/2020" 3271.12 "08/31/2020" 3500.31 "09/30/2020" 3363 "10/30/2020" 3269.96 "11/30/2020" 3621.63 "12/31/2020" 3756.07 "01/29/2021" 3714.24 "02/26/2021" 3811.15 "03/31/2021" 3972.89 "04/30/2021" 4181.17 "05/28/2021" 4204.11 "06/30/2021" 4297.5 "07/30/2021" 4395.26 "08/31/2021" 4522.68 "09/30/2021" 4307.54 "10/29/2021" 4605.38 "11/30/2021" 4567 "12/31/2021" 4766.18 "01/31/2022" 4515.55 "02/28/2022" 4373.94 "03/31/2022" 4530.41 "04/29/2022" 4131.93 "05/31/2022" 4132.15 "06/30/2022" 3785.38 "07/29/2022" 4130.29 "08/31/2022" 3955 "09/30/2022" 3585.62 "10/31/2022" 3871.98 "11/30/2022" 4080.11 "12/31/2022" 3839.5 "01/31/2023" 4076.6 "02/28/2023" 3970.15 "03/31/2023" 4109.31 "04/28/2023" 4169.48 end
I'm using this code that's inspired by your suggestions:
gen mdate = monthly(substr(Month, 1, 7), "YM")
local tickpos = ym(2015, 12) + 0.5
local ticks `tickpos'
forval y = 2015/2025 {
local labelpos = `tickpos' + 6
local labels `labels' `labelpos' "`y'"
local tickpos = ym(`y', 12) + 0.5
local ticks `ticks' `tickpos'
}
label var Value " Value "
line Value mdate, lc(red blue) yla(, ang(h)) ytitle(%, orient(horiz)) xla(`labels', noticks) xticks(`ticks', tlength(*3)) xtitle("") legend(ring(0) pos(11) col(1)) xsc(r(. `=ym(2025, 6)')) xli(`ticks', lc(gs12))
Yet, I do get an empty graph without the line of the index that I'm studying.
Any help with this code please?
With many thanks!

Comment