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

axhline/axvline broken with pint.Quantity #8910

Closed
@dopplershift

Description

@dopplershift

With matplotlib 2.0.2, you can't use pint.Quantity withaxhline oraxvline:

%matplotlibinlineimportmatplotlib.pyplotaspltimportpintunits=pint.UnitRegistry()fig,axes=plt.subplots(1,1)axes.axhline(0*units.meter)

yields:

---------------------------------------------------------------------------ValueError                                Traceback (most recent call last)<ipython-input-3-b77d6298b805> in <module>()6 units= pint.UnitRegistry()7 fig, axes= plt.subplots(1,1)----> 8 axes.axhline(0 * units.meter)~/miniconda3/envs/py36/lib/python3.6/site-packages/matplotlib/axes/_axes.py in axhline(self, y, xmin, xmax, **kwargs)720self._process_unit_info(ydata=y,kwargs=kwargs)721         yy=self.convert_yunits(y)--> 722         scaley = (yy < ymin) or (yy > ymax)723724         trans=self.get_yaxis_transform(which='grid')~/miniconda3/envs/py36/lib/python3.6/site-packages/pint/quantity.py in <lambda>(self, other)   1075                   other.to_root_units().magnitude)   1076 -> 1077     __lt__ = lambda self, other: self.compare(other, op=operator.lt)   1078     __le__ = lambda self, other: self.compare(other, op=operator.le)   1079     __ge__ = lambda self, other: self.compare(other, op=operator.ge)~/miniconda3/envs/py36/lib/python3.6/site-packages/pint/quantity.py in compare(self, other, op)   1065                 return op(self._convert_magnitude_not_inplace(UnitsContainer()), other)   1066             else:-> 1067                 raise ValueError('Cannot compare Quantity and {0}'.format(type(other)))   1068    1069         if self._units == other._units:ValueError:Cannot compare Quantity and <class 'numpy.float64'>

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