-
Notifications
You must be signed in to change notification settings - Fork 813
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
Look in to a Textual wrapper for Plottext #3029
Comments
The first thing that leaps out at me with this, and I'm sure there's a way around this, is that it follows the approach of some other plotting libraries I've seen and worked with where they're built for easy use in the REPL, but aren't so obvious for use in actual applications where you may have multiple separate plots happening at once (back in the day I remember matplotlib being quite difficult to use in this sense). So a lot of the example code I'm seeing is stuff like: import plotext as plt
plt.do_this()
plt.do_that()
plt.do_the_other()
plt.show() with no examples of how you create two or more plots that have nothing to do with each other, in parallel; it all seems to be working on one single plot that's a singleton within the library. Like I say: I would think (hope) there's a way of handling this, but I'm noting the issue here as something I need to dive into the docs further for. |
After consuming the docs, and working through the code for the the library, it looks like the whole thing is very much built around the idea that any code using the library is only working on one plot at once (possibly with sub-plots; but they're part of the same parent plot); there's no (public) method of saying "give me a plot, let me work on that, oh and give me another plot and let me work on that too in parallel". This sort of approach is fine for a simple procedural body of code that's only working on a single plot, but possibly not so great for trying to make a Textual widget from it; at least not without some compromises. I was hoping we could make a widget that would be a thin wrapper around some plotting object within the library, and that building and updating multiple copies of such a widget would be easy and straightforward. Either I'm missing the obvious here, or this isn't going to be that simple. None of this is to say it can't be done; it's more a case of the library doesn't seem to be designed to be "do stuff in parallel" friendly. (FWIW, I saw this exact same problem with matplotlib, which seems to be the inspiration for this library, back in the day -- eventually I seem to remember them adding a "class-based" system that allowed it) |
I think we have to wrap plottext in such a way that we can store the plot information, then in a |
Annoyingly, it's looking like something like that will have to be the approach, likely some sort of interface that captures the attempted function calls and arguments, and then plays them back in a single blocked call; that sort of thing. |
Pretty much. An alternative might be to use processes to render the plots. That could be a huge win, in that multiple plots can be rendered in parallel. And you wouldn't have to deal with the issue of the singleton approach. |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
https://github.com/piccolomo/plotext/blob/master/readme/environments.md#rich
It already works with Rich. Perhaps we can add a Widget wrapper.
The text was updated successfully, but these errors were encountered: