Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Log Scale: FloatingPointError: underflow encountered in power #15331

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

Closed
ptoews opened this issue Sep 23, 2019 · 1 comment · Fixed by #15258
Closed

Log Scale: FloatingPointError: underflow encountered in power #15331

ptoews opened this issue Sep 23, 2019 · 1 comment · Fixed by #15258
Milestone

Comments

@ptoews
Copy link

ptoews commented Sep 23, 2019

Bug report

Bug summary

When setting the scale to log on an empty axis while having numpy error handling set to raise, a FloatingPointError is thrown. When plotting data beforehand, everything works fine.

This is an issue for me, because I'm trying to plot multiple subplots with shared y axes after each other, where this issue occurs as well. For some reason in that context the error handling seems to bet set to raise.

Issue #4285 is related but the stack trace is different and this issue is not dependent on data.

Code for reproduction

import matplotlib.pyplot as plt
import numpy as np

np.seterr(all="raise")

#plt.plot([1], [1])
plt.yscale("log")

Actual outcome

Traceback (most recent call last):
  File ".../.PyCharmCE2019.2/config/scratches/scratch_44.py", line 7, in <module>
    plt.yscale("log")
  File ".../venv/lib/python3.6/site-packages/matplotlib/pyplot.py", line 3088, in yscale
    return gca().set_yscale(value, **kwargs)
  File ".../venv/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 3711, in set_yscale
    self.autoscale_view(scalex=False)
  File ".../venv/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 2498, in autoscale_view
    'minposy', self.yaxis, self._ymargin, y_stickies, self.set_ybound)
  File ".../venv/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 2486, in handle_single_axis
    x0, x1 = inverse_trans.transform([x0t, x1t])
  File ".../venv/lib/python3.6/site-packages/matplotlib/transforms.py", line 1394, in transform
    res = self.transform_affine(self.transform_non_affine(values))
  File ".../venv/lib/python3.6/site-packages/matplotlib/scale.py", line 334, in transform_non_affine
    return ma.power(self.base, a)
  File ".../venv/lib/python3.6/site-packages/numpy/ma/core.py", line 6717, in power
    result = np.where(m, fa, umath.power(fa, fb)).view(basetype)
FloatingPointError: underflow encountered in power

Matplotlib version

  • Operating system: Ubuntu 18.04
  • Matplotlib version: 3.1.1
  • Matplotlib backend (print(matplotlib.get_backend())): TkAgg
  • Python version: 3.6.8
  • Other libraries: Numpy == 1.17.2

All packages were installed using pip.

@tacaswell tacaswell added this to the v3.3.0 milestone Sep 24, 2019
@anntzer
Copy link
Contributor

anntzer commented Sep 26, 2019

This is fixed by #15258.

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

Successfully merging a pull request may close this issue.

4 participants