I need to put a series of dates (timestamp) that are stored in a bd on the x-axis of a chart, the problem is that the dates overlap and an efficient analysis is impossible. Follow the code:
# -*- coding: utf-8 -*-
import MySQLdb as mdb
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as dates
con = mdb.connect('localhost', 'testuser', '*******', 'testdb')
with con:
f = []
cur = con.cursor()
conversor = dates.strpdate2num('%Y-%m-%d %H:%M:%S')
a = cur.execute("SELECT Ping FROM Pings WHERE Enderecos ='186.209.34.78'")
a = cur.fetchall()
row = cur.execute("SELECT Timestamp FROM Pings WHERE Enderecos = '186.209.34.78'")
for i in range(cur.rowcount):
row= cur.fetchone()[0]
f.append(conversor(row))
plt.xlabel("Timestamp")
plt.ylabel("Ping")
plt.plot_date(f,a)
plt.title("186.209.34.78")
plt.show()
Withzoom: