8000 NaN positional argument to `ax.text` fails silently notebook backend. · Issue #9267 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
NaN positional argument to ax.text fails silently notebook backend. #9267
Closed
@jklymak

Description

@jklymak

Bug report

Bug summary

Calling ax.text with a non-finite x or y fails silently in jupyter notebook

Code for reproduction

I ran into this while trying to label a bunch of lines. Some of my x, y were np.NaN because the lines didn't need to exist. Trimming my x and y is a fine workaround, but it took a while to find the error because it fails silently in jupyter notebook.

import matplotlib.pyplot as plt
import numpy as np

fig, ax = plt.subplots(1, 2)

for axx in ax:
    axx.text(1., 2., 'boo')
    axx.text(np.NaN, np.NaN, 'boo!')

Fails with

ValueError: posx and posy should be finite values

when calling from the command line. But if I execute the above in a jupyter notebook, it draws the first axis and then drawing silently fails, with no error message.

Expected outcome

I guess that __init__ should check if x and y are finite and fail at that point rather than let the rest of the plot be setup and then fail on draw. However, there is a set_xy method, so maybe it has to wait until draw. In which case, I'm not sure why the error is silent in the notebook backend...

Matplotlib version

  • Operating system: OSX
  • Matplotlib version: master and 2.0.1
  • Matplotlib backend (print(matplotlib.get_backend())): MacOSX, notebook
  • Python version: 3.6
  • Jupyter version (if applicable): 4.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0