Relative Content

Tag Archive for matplotlibaxisaxis-labels

plot the x axis as MM:SS instead of integer in a histogram

I have ambulance response time data as seconds. For example (32, 158, 36, 459, 830, 396). I am able to make a Matplotlib histogram binning the data into 60 second increments. On the x axis label the data is labelled as 0 – 60 – 120 – 180 etc. I would like the x axis label to show 00:00 – 01:00 – 02:00 – 03:00 etc. In other words, instead of seconds as integer values, it should show seconds formatted as mm:ss.
The code below comes close but I am not able to make it work. The code below only returns 00:00 for all bins.
How can I label the x axis of a histogram as mm:ss instead of integers?

plot the x axis as MM:SS instead of integer in a histogram

I have ambulance response time data as seconds. For example (32, 158, 36, 459, 830, 396). I am able to make a Matplotlib histogram binning the data into 60 second increments. On the x axis label the data is labelled as 0 – 60 – 120 – 180 etc. I would like the x axis label to show 00:00 – 01:00 – 02:00 – 03:00 etc. In other words, instead of seconds as integer values, it should show seconds formatted as mm:ss.
The code below comes close but I am not able to make it work. The code below only returns 00:00 for all bins.
How can I label the x axis of a histogram as mm:ss instead of integers?