Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in Bar Plot with Same Height Data #61

Closed
SoyBison opened this issue Dec 7, 2021 · 1 comment
Closed

Error in Bar Plot with Same Height Data #61

SoyBison opened this issue Dec 7, 2021 · 1 comment

Comments

@SoyBison
Copy link

SoyBison commented Dec 7, 2021

Minimal example included

plt.bar(['a', 'b', 'c'], [1,1,1])
plt.show()
Traceback (most recent call last):
  File "/home/coen/Documents/Macrohard/ProjectRatio/FramingSelection/venv/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 3457, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-13-1eb00ff78cf2>", line 1, in <module>
    plt.show()
  File "/home/coen/Documents/Macrohard/ProjectRatio/FramingSelection/venv/lib/python3.9/site-packages/plotext/_figure.py", line 281, in show
    self.build()
  File "/home/coen/Documents/Macrohard/ProjectRatio/FramingSelection/venv/lib/python3.9/site-packages/plotext/_figure.py", line 266, in build
    self.subplot.get_absolute_ticks()
  File "/home/coen/Documents/Macrohard/ProjectRatio/FramingSelection/venv/lib/python3.9/site-packages/plotext/_subplot.py", line 271, in get_absolute_ticks
    self.rticks = [get_matrix_data(self.yticks[s], self.ylim[s], self.height_canvas) for s in range(2)]
  File "/home/coen/Documents/Macrohard/ProjectRatio/FramingSelection/venv/lib/python3.9/site-packages/plotext/_subplot.py", line 271, in <listcomp>
    self.rticks = [get_matrix_data(self.yticks[s], self.ylim[s], self.height_canvas) for s in range(2)]
  File "/home/coen/Documents/Macrohard/ProjectRatio/FramingSelection/venv/lib/python3.9/site-packages/plotext/_utility/plot.py", line 30, in get_matrix_data
    data = [round((el - lim[0]) / dz + 0.5, 1)   for el in data]
  File "/home/coen/Documents/Macrohard/ProjectRatio/FramingSelection/venv/lib/python3.9/site-packages/plotext/_utility/plot.py", line 30, in <listcomp>
    data = [round((el - lim[0]) / dz + 0.5, 1)   for el in data]
ZeroDivisionError: float division by zero
@piccolomo
Copy link
Owner

piccolomo commented Dec 10, 2021

Hi @SoyBison,

thanks a lot for the issue report. I have sorted the issue in the new version 4.1.0 available on github and pypi.

Now the code:

plt.bar(['a', 'b', 'c'], [1,1,1])
plt.show()

should output:
image

Feel free to reopen if the issue persists.

All the best,
Savino.

@piccolomo piccolomo changed the title Making a barplot where all entries have the same height results in a division by zero. Error in Bar Plot with Same Height Data Dec 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants