Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
matplotlib plot to time
#1
hi, I'm plotting a lot of data with python, but I'd like to set the x axis to plot using the time and date that my data was gathered and I haven't been able to figure it out. I looked at this page that seemed like it would help but I don't understand how the code works. basically I the time and date is in a list within another list and is formatted like this: year.month.day.hour.min.sec
the list where everything is contained looks 'like this: data = [['47. 12. 23. 14. 33. 25', ..., ' 47. 12. 31. 20. 1. 13 '],[data], ..., [data]]

how do I transform data[0](the time and date) into something matplotlib can use to set the x axis?
Reply
#2
from matplotlib import dates
import datetime

d = '47. 12. 23. 14. 33. 25'

dt = datetime.datetime.strptime(d, '%y. %m. %d. %H. %M. %S') 
print(dt.date(), dt.time())

fds = dates.date2num(dt)
print(fds)
99 percent of computer problems exists between chair and keyboard.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  first time use plot - I get empty graph korenron 6 1,958 Feb-04-2023, 02:14 PM
Last Post: deanhystad
  Graphic line plot with matplotlib, text file in pytho khadija 2 1,338 Aug-15-2022, 12:00 PM
Last Post: khadija
  plot on the same figure using a for loo with matplotlib drSlump 2 1,668 Oct-13-2021, 07:11 AM
Last Post: drSlump
  matplotlib, no plot when using Figure ajvperth 2 1,652 Oct-12-2021, 02:29 PM
Last Post: ajvperth
  Matplotlib: How do I convert Dates from Excel to use in Matplotlib JaneTan 1 3,161 Mar-11-2021, 10:52 AM
Last Post: buran
  Python Matplotlib: How do I plot lines with different end point in the same graph? JaneTan 0 1,550 Feb-28-2021, 11:56 AM
Last Post: JaneTan
  How to plot intraday data of several days in one plot mistermister 3 2,854 Dec-15-2020, 07:43 PM
Last Post: deanhystad
  Difference Between Figure Axis and Sub Plot Axis in MatplotLib JoeDainton123 2 2,426 Aug-21-2020, 10:17 PM
Last Post: JoeDainton123
  Understanding The Arguments for matplotlib.pyplot.plot JoeDainton123 0 1,900 Aug-19-2020, 01:19 AM
Last Post: JoeDainton123
  How to plot gantt chart using matplotlib Mekala 1 2,586 Jul-16-2020, 07:21 PM
Last Post: Marbelous

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020