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