Skip to content

Allow pathlib.Path instances as savefig values too #380

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

Merged
merged 2 commits into from
Apr 18, 2021

Conversation

mattsta
Copy link
Contributor

@mattsta mattsta commented Apr 18, 2021

Allowing figure targets to be pathlib.Path instances makes integration easier with libraries already providing Path instances (saves unnecessary str() conversion calls since Path instances work as output too)

mattsta and others added 2 commits April 18, 2021 13:51
pathlib.Path instances are valid mpl savefig output targets too
@DanielGoldfarb
Copy link
Collaborator

Thanks. Good idea! I am assuming you have tested that this works as expected. I've just bumped the version number. Making sure each PR increases the version helps identify the code if someone reports an issue.

@DanielGoldfarb DanielGoldfarb merged commit 7617810 into matplotlib:master Apr 18, 2021
@mattsta
Copy link
Contributor Author

mattsta commented Apr 18, 2021

Thanks!

I did test the workflow on my local install and it generated the same files as using string filenames. I assume the value is just being passed through as the open() parameter for writes, so usage is interchangeable with string or BytesIO

@DanielGoldfarb
Copy link
Collaborator

Thanks Matt.

Would it be any trouble for you to also contribute a pathlib.Path example to the savefig examples notebook, along with a short explanation of how and why one would want to use pathlib.Path with savefig?

All the best. --Daniel

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

Successfully merging this pull request may close these issues.

2 participants