Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_bar does not support date values on the x-axis #91

Open
seanjh opened this issue Apr 23, 2015 · 0 comments
Open

_bar does not support date values on the x-axis #91

seanjh opened this issue Apr 23, 2015 · 0 comments

Comments

@seanjh
Copy link

seanjh commented Apr 23, 2015

prettyplotlib seems to choke when the values provided on the x-axis do not support the + operator (or the "width" value does not support the / operator). My code is excerpted below. ppl.bar throws a TypeError, but ppl.plot works wonderfully.

dates = sorted(review_by_date.keys())
review_counts = [review_by_date[k] for k in x]
ma = moving_average(review_counts, 10)

fig, axes = plt.subplots(1, figsize=(16, 10))
ppl.bar(axes, dates, review_counts, annotate=False, linewidth=0)
axes.bar(dates, review_counts, color='green', linewidth=0)  # TypeError
# axes.plot(dates, ma, 'r')
ppl.plot(axes, dates, ma)  # Works
fig.autofmt_xdate()
axes.set_title('Reviews by Date')
axes.set_xlabel('Dates')
axes.set_ylabel('Reviews')
axes.fmt_xdata = mdates.DateFormatter('%Y-%m-%d')

...

prettyplotlib/_bar.pyc in bar(*args, **kwargs)
     48     xtickabels = kwargs.pop('xticklabels', None)
     49     # left+0.4 is the center of the bar
---> 50     xticks = np.array(left) + middle
     51 
     52     # Whether or not to annotate each bar with the height value
TypeError: unsupported operand type(s) for +: 'datetime.date' and 'float'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant