Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upReturning bytes data from savefig #18614
Comments
|
The current way of saving the figure as a byte string is by using None as the file name, correct? The original PR wanted to add a new method (to_bytes or write_bytes) to the fig object to make this conversion more explicit? I'm new to the community, so I would be grateful if you could give me some more guidance. |
|
No thats backwards. |
Ok, so instead of making a new method on the fig object, you're proposing that whenever |
|
Thats my understanding, but of course you should check the PR details. |
|
@tacaswell is of the opinion that we shouldn't change the return type of the |
|
... keep reading |
|
Oh alright, @tacaswell in this comment (#6909 (comment)) said that he thinks using |


Problem
#6909 is a PR, abandoned by the original author, that made
bytestring = fig.savefig(None, **kwargs)equivalent toimport io; buf = io.BytesIO(); fig.savefig(buf, **kwargs); bytestring = buf.getvalue()which is in itself a handy simplification. I think there was general agreement about the feature, it just needs some tests (which should be made simpler than in the original PR -- that was one of the remaining sticky points, I think).Proposed Solution
Revive #6909.
Additional context and prior art