You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pandas recently made the great effort to accept pathlib.Paths as inputs where traditionally strings would have to be provided for any path related requirements. Could this be done also for matplotlib?
We don't do much in the way of path manipulations, and we do need to be
compatible with the various backends we use, so internally, I don't see us
using anything else but strings. That said, it is probably feasible to make
sure that we cast those objects into strings.
pandas recently made the great effort to accept pathlib.Paths as inputs
where traditionally strings would have to be provided for any path related
requirements. Could this be done also for matplotlib?
—
Reply to this email directly or view it on GitHub #5968.
It's worth noting that there's now a path protocol outlined in https://www.python.org/dev/peps/pep-0519/. Using it you call os.fspath on a path to get a string/bytes view of the path, and the function is easy enough to backport (I've done this for h5py already). I'll try to submit a pull request in the next few days which adds this, should it be against master, or would this be small enough to the maintenance branches?
I think this has regressed? I'm getting ValueError: fname must be a PathLike or file handle with plt.savefig(Path("fitness/fitness1.png")) works with plt.savefig(str(Path("fitness/fitness1.png")))
Activity
WeatherGod commentedon Feb 5, 2016
We don't do much in the way of path manipulations, and we do need to be
compatible with the various backends we use, so internally, I don't see us
using anything else but strings. That said, it is probably feasible to make
sure that we cast those objects into strings.
On Thu, Feb 4, 2016 at 4:42 PM, K.-Michael Aye notifications@github.com
wrote:
michaelaye commentedon Feb 5, 2016
That was all I was dreaming of so that I don't have to do the casting all the time! ;)
WeatherGod commentedon Feb 5, 2016
If you can come up with a list of functions that will need to do this
casting, that would be a huge step towards getting a PR together.
On Fri, Feb 5, 2016 at 2:55 PM, K.-Michael Aye notifications@github.com
wrote:
michaelaye commentedon Feb 5, 2016
I will, just not this month, which looks like the busiest of my life… ;)
aragilar commentedon Jun 5, 2016
It's worth noting that there's now a path protocol outlined in https://www.python.org/dev/peps/pep-0519/. Using it you call os.fspath on a path to get a string/bytes view of the path, and the function is easy enough to backport (I've done this for h5py already). I'll try to submit a pull request in the next few days which adds this, should it be against master, or would this be small enough to the maintenance branches?
tacaswell commentedon Jun 5, 2016
Please target it at 2.x.
anntzer commentedon Jan 22, 2018
Closed by #10231.
LukeIreland1 commentedon Mar 12, 2020
I think this has regressed? I'm getting
ValueError: fname must be a PathLike or file handlewithplt.savefig(Path("fitness/fitness1.png"))works withplt.savefig(str(Path("fitness/fitness1.png")))tacaswell commentedon Mar 12, 2020
@LukeIreland1 Please open a new issue with your version details etc.