Sometimes, the data returned from the server has '0' for all day and night counts. When plotting, this results in a ZeroDi
visionError exception:
>>> import plotext as plt
>>> dates = ['2022-01-01', '2022-01-02', '2022-01-03']
>>> dayc = [0, 0, 0]
>>> nightc = [0, 0, 0]
>>> plt.bar(dates, dayc)
>>> plt.show()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/barbe/Projects/installer_tools/.venv/lib/python3.9/site-packages/plotext/_figure.py", line 285, in show
self.build()
File "/Users/barbe/Projects/installer_tools/.venv/lib/python3.9/site-packages/plotext/_figure.py", line 269, in build
self.subplot.get_relative_ticks()
File "/Users/barbe/Projects/installer_tools/.venv/lib/python3.9/site-packages/plotext/_subplot.py", line 285, in get_relative_ticks
self.rticks = self._get_relative_ticks(self.yticks, self.ylim, self.height_canvas)
File "/Users/barbe/Projects/installer_tools/.venv/lib/python3.9/site-packages/plotext/_subplot.py", line 291, in _get_relative_ticks
ticks = [get_matrix_data(ticks[s], lim[s], bins) for s in range(2)]
File "/Users/barbe/Projects/installer_tools/.venv/lib/python3.9/site-packages/plotext/_subplot.py", line 291, in <listcomp>
ticks = [get_matrix_data(ticks[s], lim[s], bins) for s in range(2)]
File "/Users/barbe/Projects/installer_tools/.venv/lib/python3.9/site-packages/plotext/_utility/plot.py", line 29, in get_matrix_data
data = [round((el - lim[0]) / dz + 0.5, 1) for el in data] if lim[0] != None else [None] * len(data)
File "/Users/barbe/Projects/installer_tools/.venv/lib/python3.9/site-packages/plotext/_utility/plot.py", line 29, in <listcomp>
data = [round((el - lim[0]) / dz + 0.5, 1) for el in data] if lim[0] != None else [None] * len(data)
ZeroDivisionError: float division by zero
>>> plt.stacked_bar(dates, [dayc, nightc])
>>> plt.show()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/barbe/Projects/installer_tools/.venv/lib/python3.9/site-packages/plotext/_figure.py", line 285, in show
self.build()
File "/Users/barbe/Projects/installer_tools/.venv/lib/python3.9/site-packages/plotext/_figure.py", line 269, in build
self.subplot.get_relative_ticks()
File "/Users/barbe/Projects/installer_tools/.venv/lib/python3.9/site-packages/plotext/_subplot.py", line 285, in get_relative_ticks
self.rticks = self._get_relative_ticks(self.yticks, self.ylim, self.height_canvas)
File "/Users/barbe/Projects/installer_tools/.venv/lib/python3.9/site-packages/plotext/_subplot.py", line 291, in _get_relative_ticks
ticks = [get_matrix_data(ticks[s], lim[s], bins) for s in range(2)]
File "/Users/barbe/Projects/installer_tools/.venv/lib/python3.9/site-packages/plotext/_subplot.py", line 291, in <listcomp>
ticks = [get_matrix_data(ticks[s], lim[s], bins) for s in range(2)]
File "/Users/barbe/Projects/installer_tools/.venv/lib/python3.9/site-packages/plotext/_utility/plot.py", line 29, in get_matrix_data
data = [round((el - lim[0]) / dz + 0.5, 1) for el in data] if lim[0] != None else [None] * len(data)
File "/Users/barbe/Projects/installer_tools/.venv/lib/python3.9/site-packages/plotext/_utility/plot.py", line 29, in <listcomp>
data = [round((el - lim[0]) / dz + 0.5, 1) for el in data] if lim[0] != None else [None] * len(data)
ZeroDivisionError: float division by zero