0

I'm trying to create a line plot in Seaborn, but I'm having an issue with a gap in the plot. I have two columns and the second column should continue after the first has finished. However the gap is't filling, as I assume it's trying to extrapolate the missing dates in the dataframe.

enter image description here

I'm trying to close the gap between these time-series, such that march continues after September. This is wat my dataframe looks like between the gap.

+------------+-------+-------+
|    Date    | Val1  | Val2  |
+------------+-------+-------+
| 2020-09-24 | 199.0 | NaN   |
| 2020-09-25 | 200.0 | NaN   |
| 2021-01-03 | NaN   | 200.0 |
| 2021-01-04 | NaN   | 201.0 |
+------------+-------+-------+

The code is rather simple.

sns.lineplot(x='Date', y="vals", hue=vals, data=df, dashes=[(),(3,1)])
  • So you basically want to cut a part out of your x-axis? [This question](https://stackoverflow.com/questions/43006289/is-it-possible-to-draw-a-broken-axis-graph-with-seaborn) should help. – debsim Jun 18 '20 at 08:15

1 Answers1

0

I solved the problem by formatting the date as a string

df['Date'].dt.strftime('%Y-%m-%d')