matplotlib: plot milliseconds time series in human readable format

elecstud

I have a list of integers representing a time series in milliseconds. Each value was obtained by calling int(time.time() * 1000) and appending to the list.

Now I would like to make a plot using matplotlib that will display the milliseconds time series on the x-axis in the format "%H:%M:%S".

I tried using these values along with a matplotlib data formatter by setting: plt.gca().xaxis.set_major_formatter(dates.DateFormatter("%H:%M:%S")) but I got the following error when attempting to plot: OverflowError: int too big to convert.

I have also tried using already preformatted time series values as strings by calling time.strftime('%H:%M:%S', time.gmtime(time.time())) and appending to the list instead with no luck, resulting in this problem: Using categorical units to plot a list of strings that are all parsable as floats or dates. If these strings should be plotted as numbers, cast to the appropriate data type before plotting.

Could anyone please help me to plot milliseconds in a human readable format on the x-axis?

Stef

You can convert time values (which are ms since epoch in UTC) using epoch2num. Then you can use the standard DateFormatter.

import matplotlib.pyplot as plt
import matplotlib as mpl
import time

now_ms = int(time.time() * 1000)
x = [now_ms+t for t in range(0,10_000,1000)]

plt.plot([mpl.dates.epoch2num(t/1000) for t in x], range(10))
plt.gca().xaxis.set_major_formatter(mpl.dates.DateFormatter("%H:%M:%S")) 

You should use matplotlib version 3.3.1 or newer.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Spark DataFrame convert milliseconds timestamp column in string format to human readable time with milliseconds

From Dev

how to convert epoch time to human readable time in milliseconds

From Dev

Convert/replace time from epoch milliseconds to human readable date in logfiles

From Dev

Android: show remaining time in human readable format

From Dev

Converting Unix Time into Human Readable Format in Excel

From Dev

Android: show remaining time in human readable format

From Dev

Using the pretty time library to show a time in a human readable format in JSF

From Dev

Human readable time parser

From Dev

Formatting date to human readable format

From Dev

Translating timestamp to Human Readable format

From Dev

Order by in SQL in human readable format

From Dev

Convert minutes into a human readable format

From Dev

date in php human readable format

From Dev

Format for human readable duration? JavaScript

From Dev

Order by in SQL in human readable format

From Dev

date in php human readable format

From Dev

Format size in bytes as human readable

From Dev

Export RSAParameters to human readable format

From Dev

Drop the date from a matplotlib time series plot

From Dev

How to plot Time Series using matplotlib Python

From Dev

Matplotlib/Pandas: Zoom Part of a Plot with Time Series

From Dev

How to plot Time Series using matplotlib Python

From Dev

Matplotlib/Pandas: Zoom Part of a Plot with Time Series

From Dev

Create time series in milliseconds

From Dev

Create time series in milliseconds

From Dev

Converting human readable dates to milliseconds and back again without losing information

From Dev

How do I get the difference of time in human readable format with Laravel 5?

From Dev

TO_DATE usage in Apache Drill to convert UNIXTIMESTAMP to human readable time format

From Java

Dependency to format values to human readable form in Kotlin

Related Related

  1. 1

    Spark DataFrame convert milliseconds timestamp column in string format to human readable time with milliseconds

  2. 2

    how to convert epoch time to human readable time in milliseconds

  3. 3

    Convert/replace time from epoch milliseconds to human readable date in logfiles

  4. 4

    Android: show remaining time in human readable format

  5. 5

    Converting Unix Time into Human Readable Format in Excel

  6. 6

    Android: show remaining time in human readable format

  7. 7

    Using the pretty time library to show a time in a human readable format in JSF

  8. 8

    Human readable time parser

  9. 9

    Formatting date to human readable format

  10. 10

    Translating timestamp to Human Readable format

  11. 11

    Order by in SQL in human readable format

  12. 12

    Convert minutes into a human readable format

  13. 13

    date in php human readable format

  14. 14

    Format for human readable duration? JavaScript

  15. 15

    Order by in SQL in human readable format

  16. 16

    date in php human readable format

  17. 17

    Format size in bytes as human readable

  18. 18

    Export RSAParameters to human readable format

  19. 19

    Drop the date from a matplotlib time series plot

  20. 20

    How to plot Time Series using matplotlib Python

  21. 21

    Matplotlib/Pandas: Zoom Part of a Plot with Time Series

  22. 22

    How to plot Time Series using matplotlib Python

  23. 23

    Matplotlib/Pandas: Zoom Part of a Plot with Time Series

  24. 24

    Create time series in milliseconds

  25. 25

    Create time series in milliseconds

  26. 26

    Converting human readable dates to milliseconds and back again without losing information

  27. 27

    How do I get the difference of time in human readable format with Laravel 5?

  28. 28

    TO_DATE usage in Apache Drill to convert UNIXTIMESTAMP to human readable time format

  29. 29

    Dependency to format values to human readable form in Kotlin

HotTag

Archive