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

Feature Request: Exceptions when Subplot Matrix is Bigger then Default #60

Closed
soraxas opened this issue Nov 22, 2021 · 3 comments
Closed

Comments

@soraxas
Copy link
Contributor

soraxas commented Nov 22, 2021

I was confused by a strange index out of bound error

  File "xxxxx/terminal-plot/lib/python3.9/site-packages/plotext/_figure.py", line 55, in set_subplot
    self.subplot = self.subplots[self.row][self.col]
IndexError: list index out of range

which, after some extensive investigation I realise it's due to

rows = rows if rows < self.default.rows_max else self.default.rows_max

and the defaults is defined in

self.cols_max = 10 # max number of subplots columns and rows


I don't oppose sane defaults (it should probably be configurable). However, this override is undetectable from user code as it is enforced in figure creation without any notice. In my opinion, it might be better off throw an exception instead of silently overrides the subplot size...

@piccolomo
Copy link
Owner

piccolomo commented Dec 4, 2021

Hi @soraxas, thanks for the report and sorry for late reply (I put aside this project for awhile after the latest version update).

I understand the issue: It seems it requires the creation of custom exceptions, which I am not familiar with yet, therefore I will work on it for next version.

Also I like the idea of giving the user the ability to configure default values, something i will also think about.

I will update and thanks

@piccolomo
Copy link
Owner

piccolomo commented Dec 10, 2021

Hi @soraxas ,

thanks a lot for the issue report. I should have sorted this in the newly updated 4.1.0 version, available on github and pypi.

Now setting a higher then 10 number of rows or cols should throw and exception.

Also in order to change the default value max value of 10, it is probably easier to do it directly instead of creating a function. Here is how:

plt.figure.default.rows_max = 13
plt.figure.default.cols_max = 20

Please let me know what you think, especially if the issue persists in any other form.

All the best,
Savino.

@soraxas
Copy link
Contributor Author

soraxas commented Dec 10, 2021

Thanks for the kind reply and update on matter, appreciate it! Thanks for the amazing work

@piccolomo piccolomo changed the title Better error message for figure max row/col Feature Request: Exceptions when Subplot Matrix is Bigger then Default 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