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
Get a plot as a string #10
Comments
Hi @JoshKarpel thanks for the request! Should be possible fairly easily. So let's say you had a function In particular right now uniplot does not guarantee a horizontal dimension, as width is the |
Definitely!
I don't think it's a deal breaker, but it might make things easier. I could certainly do without it for a first pass! My current thinking is that I'll probably be sticking the plot output inside a https://rich.readthedocs.io/en/stable/reference/text.html#rich.text.Text , and I can disable wrapping - but that means the plot might get cut off if I don't guess the width right. |
Thanks @JoshKarpel! I'll have a look over the weekend, but I think it shouldn't be too hard, might actually end up with more readable code when splitting the plot generation and text output. I also thought about limiting the bounding box of the plot, this should also be possible by computing the vertical axis labels first, and then shrinking the plot window if needed. But I'll leave this for a later date. |
This adds functionality for #10. Version bump to 0.4.4.
Hi @JoshKarpel I just added such a function in version Haven't gotten around to do the "hard cap on line length" part yet, but hope this helps already. If you can share I'd be curious to see what you end up with on your side! |
It's working really well so far! JoshKarpel/spiel#33 |
Very cool! 😄 Looking forward to see how Spiel progresses |
I'm working on a tool that I would love to be able to integrate
uniplot
into, but I'm running into a problem: I need to capture the output as a string so that I can display it elsewhere. Right now,uniplot.plot
prints directly to stdout: https://github.com/olavolav/uniplot/blob/master/uniplot/uniplot.py#L74I'm not sure how to square this with the interactive features implemented in that function. Perhaps a helper function could be extracted that returns the plot as a string? Then I could call that function from my tool to get the string that
uniplot.plot
would have displayed.Happy to do the work on this if you can provide some guidance on how you'd like it implemented!
The text was updated successfully, but these errors were encountered: