python - Matplotlib bar plot with pandas Timestamp -


i having trouble making simple example work:

from numpy import datetime64 pandas import series import matplotlib.pyplot plt import datetime  x = series ([datetime64("2016-01-01"),datetime64("2016-02-01")]).astype(datetime) y = series ([0.1 , 0.2])  ax = plt.subplot(111) ax.bar(x, y, width=10) ax.xaxis_date()  plt.show() 

the error is:

typeerror: float() argument must string or number, not 'timestamp' 

note astype(datetime) piece - tried after reading other post. without piece, same error.

on other hand, example works enough plain datetime64 types - is, changing these 2 lines:

x = [datetime64("2016-01-01"),datetime64("2016-02-01")] y = [0.1 , 0.2] 

so issue must timestamp type pandas converts datetime64 objects into. there way make work timestamp directly, , not revert datetime64? i'm using series/timestamp here because real objective plotting series dataframe. (note: cannot use dataframe plotting methods because real example inside seaborn facetgrid , have use matplotlib directly.)

use:

ax.bar(x.values, y, width=10) 

when using series objects. issue not sending object similar array, indexed array matplotlib not know how handle. values returns array


Comments

Popular posts from this blog

Formatting string according to pattern without regex in php -

c - zlib and gdi32 with OpenSSL? -

java - inputmismatch exception -