Below I have the following script that creates a simple time series chart:
%matplotlib inline import datetime import pandas as pd import seaborn as sns import matplotlib.pyplot as plt fig, ax = plt.subplots() df = [] start_date = datetime.datetime(2015, 7, 1) for i in range(10): for j in [1,2]: unit = 'Ones' if j == 1 else 'Twos' date = start_date + datetime.timedelta(days=i) df.append({ 'Date': date.strftime('%Y%m%d'), 'Value': i * j, 'Unit': unit }) df = pd.DataFrame(df) sns.tsplot(df, time='Date', value='Value', unit='Unit', ax=ax) fig.autofmt_xdate()
And the result of this is the following:

As you can see, the x axis has strange numbers for datetimes, not the usual "nice" views that come with matplotlib and other charting utilities. I tried many things, reformatted the data, but it is never clean. Does anyone know the way?
python matplotlib datetime seaborn
sedavidw
source share