Skip to content Skip to sidebar Skip to footer

Overflowerror With Matplotlib And Datetime

I am getting an overflow error when I try and make a scatter plot with a datetime: import numpy as np import pandas as pd import matplotlib.pyplot as plt list_data = ['2016-10-06

Solution 1:

You cannot plot a pandas series with scatter. What you want is to plot its values only.

axes.scatter(data.slave.values, data.baseline.values)

Complete example:

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

list_data  = ['2016-10-06', '2016-09-24', 55, 'dummy', 0.510823, 0.29431]
columns    = ['master', 'slave', 'baseline', 'coh', 'coh_mean', 'coh_std']
dict_data  = dict(zip(columns, list_data))
data       = pd.DataFrame.from_dict(dict_data, orient='index').T
data.slave = pd.to_datetime(data.slave)
fig, axes  = plt.subplots()
axes.scatter(data.slave.values, data.baseline.values)
plt.show()

results in

enter image description here

Post a Comment for "Overflowerror With Matplotlib And Datetime"