Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ax.bar doesn't work correctly when width is a timedelta64 object #11290

Closed
@astrofrog

Description

@astrofrog

The following example

In [1]:x=np.array(range(100),dtype='M8[D]')In [2]:ax=plt.subplot(1,1,1)In [3]:y=np.random.random(100)In [4]:ax.bar(x,y)Out[4]:<BarContainerobjectof100artists>

works fine, but if I set width to be the diff of thedatetime64 array, which gives atimedelta64 array, things break:

In [7]:ax.bar(x[:-1],y[:-1],width=np.diff(x))---------------------------------------------------------------------------TypeErrorTraceback (mostrecentcalllast)<ipython-input-7-f05692d600cb>in<module>()---->1ax.bar(x[:-1],y[:-1],width=np.diff(x))~/miniconda3/envs/dev/lib/python3.6/site-packages/matplotlib/__init__.pyininner(ax,*args,**kwargs)1853"the Matplotlib list!)"% (label_namer,func.__name__),1854RuntimeWarning,stacklevel=2)->1855returnfunc(ax,*args,**kwargs)18561857inner.__doc__=_add_data_doc(inner.__doc__,~/miniconda3/envs/dev/lib/python3.6/site-packages/matplotlib/axes/_axes.pyinbar(self,*args,**kwargs)2257ifalign=='center':2258iforientation=='vertical':->2259left=x-width/22260bottom=y2261eliforientation=='horizontal':TypeError:ufuncsubtractcannotuseoperandswithtypesdtype('float64')anddtype('<m8[D]')

This should however be unambiguous, so it would be nice if it worked.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp