Home > Software design >  Is there a way to make Pandas area chart with time axes on x not to overlap?
Is there a way to make Pandas area chart with time axes on x not to overlap?

Time:10-27

I am trying to display a data frame of a time series with 2 columns. Here is an example of the data frame.

index Alive T-3 Alive T-3 & T 3
12/31/2018 100 80
12/31/2019 120 90
12/31/2020 130 95
12/31/2021 140 98
12/31/2022 150 100
12/31/2023 160 123

This is what I am using to plot the chart

survived.plot.area(stacked=False)

The problem I am running into is that I have 621 entries in my time series and the plot end ups looking like that. Is there a way to have it more sparse? I don't really need the whole time series on the axes. Even years would be enough.

Chart

CodePudding user response:

as @It_is_Chris mentioned, the index should be a datetime.

survived.index = pd.to_datetime(survived.index) did the work

Worked

  • Related