Home > database >  Can I create a time series with a reverse-log axis scale, so more recent dates are wider apart?
Can I create a time series with a reverse-log axis scale, so more recent dates are wider apart?

Time:09-01

In a few recent applications I have plotted some time series where the more recent values are of more interest, but the historical values are good for context. Here's an example, a plot of progress on a dissertation

Ideally I would like the more recent dates to be shown more spread out on the x-axis, but still labelled correctly as dates. This would look a bit like a logarithmic scale in reverse. I think this idea might be quite useful for timelines in contexts where progress accelerates over time, e.g. computation power.

I've looked at this enter image description here

CodePudding user response:

You may try something along these lines, i.e. converting your dates to number of days and then applying np.log10() on them:

prog.loc[:,'days'] = -np.log10(abs((prog.when - prog.iloc[-1].when).dt.days - 100))
g = sns.lineplot(x="days",y="words",data=prog,markers=True,marker="o")
_ = g.set_xticks(prog.days.to_list(), prog.when.dt.date.to_list(), rotation=90)

This yields this plot:

enter image description here

You can then handle overlapping labels by manually adjusting the xticklabels.

  • Related