I have a simple dataset of X and Y values I am plotting in matplotlib. The independent variable in my data is a duration/timedelta (e.g. 60 seconds, 2 hours, 24 hours, 10 days), which in my input data is always represented as an integer number of seconds. My question is, does matplotlib have any way of setting the duration axis labels intelligently, in a human readable form?
For example, at the small end of the scale, it would be desirable to show say 30 seconds simply as "30 seconds". At the large end of the scale, it would be nicer to show "10 days" rather than 864000 seconds. Somewhere in between, it would be better to have the labels read in "minutes" and "hours". Does matplotlib have any automated way of inferring something approximately human readable for durations spanning several orders of magnitude?
Ideally whatever approach I use should generalize to datasets that span different duration timescales, rather than a plot that is individually tailored to one input dataset.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…