I want to draw a line, where x-values are defined by years. The actual values should be a connect by a solid line, but the forecast only as dashed line.
My data would be
x | y |
---|---|
1980 | 5 |
1990 | 10 |
2000 | 17 |
2010 | 27 |
2020 | 39 |
2022 | 44 |
2030 | 60 |
To get the graph i use but of
plot 'input.dat' using 1:2 with lines dashtype 1
but of course, the whole line is solid. Is there a way to define different dashtypes for a given xrange, e.g. something like
plot 'input.dat' using 1:2 with lines from 1980 dashtype 1 from 2022 dashtype 0
I think a possible solution would be to use multiplots and draw 2 lines, but that seems to be an overkill, maybe there is a simpler solution?
I think i found a simpler solution than multiplots with the help of How to plot line graphs with different x-range in one figure using gnuplot
predicted(x) = (x >= 2022 ? x : 1/0)
actual(x) = (x > 2022 ? 1/0 : x)
plot 'input.dat' using (actual($1)):2 with lines dashtype 1, '' using predicted($1)):2 with lines dashtype 0