Python Forum
Format timestams on x axis using matplotlib
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Format timestams on x axis using matplotlib
#1
How to show timestamps on x axis as "%Y-%m-%d %H:%M". ts is list of timestamps and how to show on x axis only values "2018-5-23 14:00", "2018-5-23 14:15" and "2018-5-23 14:30".
My current chart shows: 23 14:00, 23 14:05, 23 14:10, 23 14:15, 23 14:20, 23 14:25, 23 14:30.
Chart

import datetime
import matplotlib.pyplot as plt
from matplotlib import style
style.use('fivethirtyeight')

ts = [datetime.datetime(2018, 5, 23, 14, 0), datetime.datetime(2018, 5, 23, 14, 15), datetime.datetime(2018, 5, 23, 14, 30)]
values =[3, 7, 6]
plt.plot(ts, values, 'o-')
plt.show()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  matplotlib x-axis text move bottom upward jacklee26 3 977 May-31-2023, 04:28 AM
Last Post: jacklee26
  x-axis labels with Matplotlib Mark17 8 2,190 Mar-23-2022, 06:10 PM
Last Post: Mark17
  How to make x-axis readable with matplotlib Mark17 7 3,902 Mar-01-2022, 04:30 PM
Last Post: DPaul
  matplotlib x axis range goes over the set range Pedroski55 5 3,170 Nov-21-2021, 08:40 AM
Last Post: paul18fr
  Sample labels from excel file in order to put them on x-axis and y-axis of a plot hobbyist 11 4,303 Sep-14-2021, 08:29 AM
Last Post: hobbyist
  Graphics Formatting - X-axis Notation and Annotations - Matplotlib silviover_junior 0 1,777 Mar-17-2021, 01:19 PM
Last Post: silviover_junior
  Matplotlib: How do I convert Dates from Excel to use in Matplotlib JaneTan 1 3,214 Mar-11-2021, 10:52 AM
Last Post: buran
  matplotlib x-axis wrong order SchroedingersLion 4 4,231 Feb-23-2021, 05:42 PM
Last Post: nilamo
  Help with Matplotlib and ordering the axis theliberalguy97 3 7,955 Dec-12-2020, 08:06 PM
Last Post: deanhystad
  Difference Between Figure Axis and Sub Plot Axis in MatplotLib JoeDainton123 2 2,460 Aug-21-2020, 10:17 PM
Last Post: JoeDainton123

Forum Jump:

User Panel Messages

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