I was using PyCharm's SciView plotter (I think it is an matplotlib backend), but as it does not enable zooming panning and other functions, I disabled it. Now I get the following error thrown:

ValueError: view limit minimum -1.0 is less than 1 and is an invalid Matplotlib date value. This often happens if you pass a non-datetime value to an axis that has datetime units
Traceback (most recent call last):

And then comes a traceback that does not end in any file of my own. It starts with

File "C:\Path\To\My\Project\lib\site-packages\matplotlib\backends\backend_qt5.py", line 519, in _draw_idle
    self.draw()

but ends in

File "C:\Path\To\My\Project\lib\site-packages\matplotlib\dates.py", line 1000, in viewlim_to_dt
    .format(vmin))

Which is not a file that I wrote, so I cannot even see what function of mine is raising this exception.

At the beginning of the script I get this:

Backend Qt5Agg is interactive backend. Turning interactive mode on.

I managed to narrow the source of the problem down a little bit by commenting out a few lines but this is a tedious process and I imagine there is a more expedient way to do this.

How can I find out exactly what line of code is raising this error?

1 Answers

0
user10414280 On Best Solutions

The traceback does show the line that causes the interpreter error, even if it is not in your source. Stepping through your code to reveal an error-causing state is how you find the problem.

The PyCharm debugger makes this less tedious. Use the "step into" function with your variables as watches until you reach the error.

Or...

If SciView is working (just not in interactive mode), try a backend other than Qt, like TkAgg.

matplotlib.use('TkAgg')

Interactive mode works with several graphical backends, and you may need to try all of them to find the best fit.