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

Hist Plot not Working #15

Closed
robintw opened this issue Mar 8, 2021 · 2 comments
Closed

Hist Plot not Working #15

robintw opened this issue Mar 8, 2021 · 2 comments

Comments

@robintw
Copy link

robintw commented Mar 8, 2021

I've been trying to run the example code provided in the README for the hist function:

import plotext as plt
import random
data = [random.gauss(0, 1) for el in range(50000)]
data2 = [random.gauss(3, 1) for el in range(50000)]
plt.clp()
bins = 60
plt.hist(data, bins, label="mean 0")
plt.hist(data2, bins, label="mean 3")
plt.title("Histogram plot")
plt.xlabel("data bin")
plt.ylabel("frequency")
plt.figsize(100, 30)
plt.show()

I get the following error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-1-e704a9ff5ccd> in <module>
     11 plt.ylabel("frequency")
     12 plt.figsize(100, 30)
---> 13 plt.show()

~/anaconda3/envs/pepys_py38/lib/python3.8/site-packages/plotext/plot.py in show()
    335     _size_max()
    336 
--> 337     _height_min()
    338     _height()
    339 

~/anaconda3/envs/pepys_py38/lib/python3.8/site-packages/plotext/plot.py in _height_min()
    372 def _height_min():
    373     par.height_title = int(par.title != "")
--> 374     par.height_xaxis = int(par.axes[0] or par.frame)
    375     par.height_xticks = bool(par.ticks[0])
    376     par.height_labels = int(par.xlabel != "" or par.ylabel != "")

TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

It seems like par.axes[0] or par.frame aren't initialised properly? Do you have any idea how to fix this?

@piccolomo
Copy link
Owner

piccolomo commented Mar 9, 2021

Hi robintw,

thanks for reporting the issue. I have just updated the package and it should work now. Try upgrading to version 2.3.1 (from 2.3.0), possibly using pip install plotext --upgrade.

I hope it helps, but please let me know if not and I will reopen the issue.
Thanks,
Savino

@robintw
Copy link
Author

robintw commented Mar 10, 2021

Thanks for the prompt response, it works fine now.

@piccolomo piccolomo changed the title Error when running hist example Hist Plot not Working Dec 11, 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