ValueError: view limit minimum 0.0 is less than 1 and is an invalid Matplotlib date value

2024/10/8 2:27:00

I've been given the python script where matplotlib is used , when running the script it opens the window and display graph. its working perfectly on my laptop. But this error occurs when I upload the file on AWS elasticbeanstalk. I successfully reproduce this error in my laptop by using

import matplotlib
matplotlib.use('agg')

the error raised from

File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/dates.py", line 1001, in viewlim_to_dt
.format(vmin))

here is the code in that file

def viewlim_to_dt(self):"""Converts the view interval to datetime objects."""print(self.axis)vmin, vmax = self.axis.get_view_interval()if vmin > vmax:vmin, vmax = vmax, vminif vmin < 1:raise ValueError('view limit minimum {} 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'.format(vmin))return num2date(vmin, self.tz), num2date(vmax, self.tz)

print(self.axis) shows this and then raises error

XAxis(100.000000,373.620690)

when I remove the line matplotlib.use('agg') , print(self.axis) shows

XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(200.000000,110.000000)XAxis(59.111111,106.555556)XAxis(59.111111,106.555556)XAxis(59.111111,106.555556)XAxis(59.111111,106.555556)XAxis(59.111111,106.555556)XAxis(59.111111,106.555556)XAxis(59.111111,106.555556)XAxis(59.111111,106.555556)XAxis(59.111111,106.555556)XAxis(59.111111,106.555556)XAxis(59.111111,106.555556)XAxis(59.111111,106.555556)XAxis(59.111111,106.555556)XAxis(59.111111,106.555556)XAxis(59.111111,106.555556)XAxis(59.111111,106.555556)XAxis(59.111111,106.555556)XAxis(59.111111,106.555556)XAxis(59.111111,106.555556)XAxis(59.111111,106.555556)XAxis(225.000000,88.000000)XAxis(225.000000,88.000000)XAxis(225.000000,88.000000)XAxis(225.000000,88.000000)XAxis(225.000000,88.000000)XAxis(225.000000,88.000000)XAxis(225.000000,88.000000)XAxis(225.000000,88.000000)XAxis(225.000000,88.000000)XAxis(225.000000,88.000000)XAxis(225.000000,88.000000)XAxis(225.000000,88.000000)XAxis(225.000000,88.000000)XAxis(225.000000,88.000000)XAxis(225.000000,88.000000)XAxis(225.000000,88.000000)XAxis(225.000000,88.000000)XAxis(225.000000,88.000000)XAxis(225.000000,88.000000)XAxis(225.000000,88.000000)XAxis(225.000000,88.000000)XAxis(225.000000,88.000000)XAxis(225.000000,88.000000)XAxis(225.000000,88.000000)XAxis(122.930556,106.555556)XAxis(122.930556,106.555556)XAxis(122.930556,106.555556)XAxis(122.930556,106.555556)

Can anyone helps me out, I don't know what's going on. I'm using python3 here is my full import

# -*- coding: utf-8 -*-
import numpy as np
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
import datetime
from matplotlib.dates import DateFormatter
from matplotlib.dates import HourLocator

here is the full error trace

File "/Users/abc/project/pythonfile.py", line 301, in plot_nowfacecolor='tab:purple', interpolate=True, alpha = 0.3, label='my_label')File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/__init__.py", line 1785, in innerreturn func(ax, *args, **kwargs)File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/axes/_axes.py", line 5021, in fill_betweenself._process_unit_info(xdata=x, ydata=y1, kwargs=kwargs)File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 2111, in _process_unit_infokwargs = _process_single_axis(xdata, self.xaxis, 'xunits', kwargs)File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 2094, in _process_single_axisaxis.update_units(data)File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/axis.py", line 1478, in update_unitsself._update_axisinfo()File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/axis.py", line 1496, in _update_axisinfoself.set_major_locator(info.majloc)File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/axis.py", line 1617, in set_major_locatorself.stale = TrueFile "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/artist.py", line 236, in staleself.stale_callback(self, val)File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/artist.py", line 63, in _stale_axes_callbackself.axes.stale = valFile "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/artist.py", line 236, in staleself.stale_callback(self, val)File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/figure.py", line 57, in _stale_figure_callbackself.figure.stale = valFile "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/artist.py", line 236, in staleself.stale_callback(self, val)File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/pyplot.py", line 568, in _auto_draw_if_interactivefig.canvas.draw_idle()File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/backend_bases.py", line 1899, in draw_idleself.draw(*args, **kwargs)File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py", line 402, in drawself.figure.draw(self.renderer)File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/artist.py", line 50, in draw_wrapperreturn draw(artist, renderer, *args, **kwargs)File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/figure.py", line 1652, in drawrenderer, self, artists, self.suppressComposite)File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/image.py", line 138, in _draw_list_compositing_imagesa.draw(renderer)File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/artist.py", line 50, in draw_wrapperreturn draw(artist, renderer, *args, **kwargs)File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 2604, in drawmimage._draw_list_compositing_images(renderer, self, artists)File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/image.py", line 138, in _draw_list_compositing_imagesa.draw(renderer)File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/artist.py", line 50, in draw_wrapperreturn draw(artist, renderer, *args, **kwargs)File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/axis.py", line 1185, in drawticks_to_draw = self._update_ticks(renderer)File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/axis.py", line 1023, in _update_tickstick_tups = list(self.iter_ticks())  # iter_ticks calls the locatorFile "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/axis.py", line 967, in iter_ticksmajorLocs = self.major.locator()File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/dates.py", line 1230, in __call__self.refresh()File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/dates.py", line 1250, in refreshdmin, dmax = self.viewlim_to_dt()File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/dates.py", line 1001, in viewlim_to_dt.format(vmin))
ValueError: view limit minimum 0.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
Answer

I've resolved my issue by myself, by comment-out this line in my code

plt.ion() 

as I said in my question, the app was running in development env (in my laptop) but not running on the AWS server. I hope, it may help someone.

https://en.xdnf.cn/q/118747.html

Related Q&A

Python win32com Outlook Stores not iterable

Trying to list all Outllook stores (and finally all e-mails in those stores):import win32com.clientoutlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI") sto…

Using a users input to search dictionary keys and print that keys matching value

I am working with tkinter, as I have my gui set up with and entry, label, and button. Im trying to search my dictionarys keys with the users input from the entry, and print the value of the key that wa…

How to write CSV into the next column

I have output that I can write into a CSV. However, because of how i setup my XML to text, the output iterates itself incorrectly. Ive tried a lot to fix my XML output, but I dont see any way to fix it…

Comparing date from pandas dataframe to current date

Im currently trying to write a script that does a specific action on a certain day. So for example, if today is the 6/30/2019 and in my dataframe there is a 6/30/2019 entry, xyz proceeds to happen. How…

How to divide a binary file to 6-byte blocks in C++ or Python with fast speed? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.Want to improve this question? Update the question so it focuses on one problem only by editing this post.Closed 5…

Selenium, python dynamic table

Im creating a robot with selenium that get all info from agencies in Brasil, ive alredy done the permutation click between all States and counties, all i have to do nows click in all agencies and get i…

How to split string into column

I got a csv file with some data, and I want to split this data.My column one contains a title, my column 2 contains some dates, and my column 3 contains some text linked to the dates.I want to tran…

remove whitespaces with new line characters

I have a string that looks like that:"\n My name is John\n and I like to go.\n blahblahblah.\n \n\n ".Note - In this string example, there are 5 white-spaces after…

Python tkinter GUI freezing/crashing

from Tkinter import * import tkFileDialog import tkMessageBox import os import ttkimport serial import timeit import time################################################################################…

If/else in python list comprehension

I would like to return random word from file, based on passed argument. But if the argument doesnt match anythning I dont want to return anything. My method looks like:def word_from_score(self,score):p…