1

For some reason matplotlib's scatter isn't able to parse datetime values but plot is. Is this a bug in matplotlib or am I doing something wrong?

import datetime
from decimal import Decimal
import matplotlib.pyplot as plt
import seaborn as sns


x = [datetime.date(2016, 10, 12),datetime.date(2017, 6, 28)]
y = [Decimal('618020.0000'), Decimal('442107.0000')]

plt.plot(x, y)

enter image description here

import datetime
from decimal import Decimal
import matplotlib.pyplot as plt
import seaborn as sns


x = [datetime.date(2016, 10, 12),datetime.date(2017, 6, 28)]
y = [Decimal('618020.0000'), Decimal('442107.0000')]

plt.scatter(x, y)

enter image description here

My matplotlib version is 1.5.3.

user554481
  • 1,875
  • 4
  • 26
  • 47
  • With your version of matplotlib, you can indeed not plot dates as scatter. Easiest solution: Update matplotlib. Second easiest solution: don't use scatter, but `plot` instead, `plt.plot(x,y, ls="", marker="o")`. Third easiest solution: convert your dates to numbers to use scatter, `xnum = matplotlib.dates.date2num(x); plt.scatter(xnum,y)` (after that you may use dateformatters to format your labels as dates). – ImportanceOfBeingErnest Nov 09 '17 at 20:18
  • Yeah, that did the trick. The issue goes away with Matplotlib version 2.1.0 – user554481 Nov 09 '17 at 20:28

0 Answers0