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

Allow export functions to export to a file-like object #885

Closed
dmoklaf opened this issue Sep 22, 2023 · 1 comment
Closed

Allow export functions to export to a file-like object #885

dmoklaf opened this issue Sep 22, 2023 · 1 comment
Assignees
Milestone

Comments

@dmoklaf
Copy link

dmoklaf commented Sep 22, 2023

The 2 image export functions (export_svg and, export_png) require a "filename" target destination.

However, some use cases don't require the filesystem. E.g., to generate and send back directly a chart PNG to a client from a web server.

It would be very convenient to be able to specify as target, alternatively to a filename, a file-like-object. This is the approach used by pandas (they call usually the argument covering both cases "path", e.g. in DataFrame.to_feather(..., path=..., ...).

This would be easy to implement, as the underlying cairosvg library can handle both of these cases with the same call.

Absent this improvement, the current workaround is to use a temporary file, which lengthens the code and involves an unnecessary write access to the filesystem (use of temp files or not, security, cleanup logic in case of crashes, etc...)

lets_plot 4.0.1
python 3.11.5
macos 13.5.2

@alshan alshan modified the milestones: New, 2023Q4 Sep 25, 2023
@alshan
Copy link
Collaborator

alshan commented Dec 28, 2023

Hi, added in v4.2.0 : example notebook.

@alshan alshan closed this as completed Dec 28, 2023
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

3 participants