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

Subplots do not Inherit from Parent Figure Properly #151

Closed
piccolomo opened this issue Oct 26, 2022 · 0 comments
Closed

Subplots do not Inherit from Parent Figure Properly #151

piccolomo opened this issue Oct 26, 2022 · 0 comments

Comments

@piccolomo
Copy link
Owner

piccolomo commented Oct 26, 2022

I spotted the following bug in version 5.2.7, which I report for clarity (as I found a fix)

This code works properly: import plotext as plt; plt.main().clf(); plt.plot([1,2]); plt.frame(0); plt.subplots(2,2); plt.show();.
The 4 subplots inherit both the plot data and the instruction of removing the frame.

Analogously this code works fine: import plotext as plt; plt.main().clf(); plt.subplots(2,2); plt.plot([1,2]); plt.main().frame(0); plt.show();
The 4 subplots do not have initial data or instrucion before being created, but the information is passed later to the global figure (and so to all its subplots) and all goes well.

This code however does not work: import plotext as plt; plt.main().clf(); plt.subplots(2,2); plt.subplot(1,1).plot([1,2]); plt.subplot(1,1).frame(0); plt.subplot(1,1).subplots(2,2); plt.show();
The situation is the same as in the first case, the difference is that there are nested subplots and in this case the inheritance does not work.

Interestingly passing the data or instructions to nested subplots, after being created works as in code 2: import plotext as plt; plt.main().clf(); plt.subplots(2,2); plt.subplot(1,1).subplots(2,2); plt.subplot(1,1).plot([1,2]); plt.subplot(1,1).frame(0); plt.show();

The issue is due to the fact that the subplots, when build, think their parent is their grand-parent (due to an error in the script). All works fine with one level subplots because grand-parent = parent here; for nested subplots instead grand-parent = main figure and not the actual parent, messing up inheritance.

Issue solved anyway in [new commit] i.e. version 5.2.8 (only on GitHub for now) (57407ad).

@piccolomo piccolomo changed the title Subplots do not Inherit Parent properly Subplots do not Inherit from Parent Figure Properly Oct 26, 2022
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

1 participant