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

Deprecate and remove pyplot.plotfile? #12180

Closed
dstansby opened this issue Sep 20, 2018 · 9 comments
Closed

Deprecate and remove pyplot.plotfile? #12180

dstansby opened this issue Sep 20, 2018 · 9 comments
Milestone

Comments

@dstansby
Copy link
Member

Currently the record array methods in the mlab module are deprecated, but pyplot.plotfile() still requires them and has not been deprecated. Does anyone have any objections to deprecating pyplot.plotfile(), and supplying users with alternative options for reading in files (e.g. numpy, pandas)?

@ImportanceOfBeingErnest
Copy link
Member

I guess this makes sense. The key would be really to provide alternatives. I think people like the simplicity of reading the data and plotting it in one line seen from often used constructs like

 pandas.read_csv("fname").plot()

I've never seen someone using pyplot.plotfile though. I don't know where in the docs that would fit, but showing matplotlib options like

plt.plot(*np.loadtxt("fname", unpack=True, usecols=(1,2)))

or

plt.plot("x", "y", data=pandas.read_csv("fname"))

might be helpful.

@WeatherGod
Copy link
Member

WeatherGod commented Sep 20, 2018 via email

@tacaswell tacaswell added this to the v3.1 milestone Sep 20, 2018
@timhoffm
Copy link
Member

timhoffm commented Sep 20, 2018

+0.5 on deprecating plotfile(). It does too much. Parsing a file and plotting are separate concerns. While it may be convenient for a user, it's not reasonable from an API point of view.

pandas.read_csv("fname").plot() does it right by chaining the different functionalities. The other two pyplot-based code snippets by @ImportanceOfBeingErnest are reasonable as well. We could just add an example for "Plotting data from a file" to promote the alternatives.

The focus of matplotlib is plotting, not parsing data out of a file. The latter is a complicated topic itself and we should not bother too much about it ourselves.

That said, I don't mind if someone has strong feelings about plotfile() and wants to take on the burden to port it to numpy.

@dstansby
Copy link
Member Author

For now I have just made csv2rec a private method (well, added an underscore to its name), which is then used in plotfile(). If anyone else wants to replace it then feel free to open a new PR.

@rudrathegreat
Copy link

Another alternative to matplotlib.pyplot.plotfile is matplotlib.pyplot.savefig which allows you to save a figure (graph) into a folder. Simply -

plt.savefig('Images/image.png')

Requirements

Python 3.7

Matplotlib 2.2.3

SciPy (if you want to save the data as an audio file)

NumPy (recommendation, if you want speed)

I hope that helped!

@WeatherGod
Copy link
Member

@rudrathegreat, uhm. I don't follow. savefig() is not an alternative to plotfile(). And I don't know why you included a requirements list there.

@jklymak
Copy link
Member

jklymak commented Nov 8, 2018

@rudrathegreat Thanks so much for your interest in Matplotlib.

When calibrating the kind of comments to post here, please note whether commenters are on the development team or not, as indicated by a "Member" badge in the heading of their posts. Most folks who are on the development team are aware of something as basic as fig.savefig.

@rudrathegreat
Copy link

rudrathegreat commented Nov 9, 2018

@jklymak and @WeatherGod . Thanks for letting me know. I thought the issue was related to saving the graph. I love Matplotlib! Thanks for letting me know!

@tacaswell tacaswell modified the milestones: v3.1.0, v3.2.0 Mar 18, 2019
@anntzer anntzer mentioned this issue Mar 22, 2019
6 tasks
@anntzer
Copy link
Contributor

anntzer commented Jul 4, 2019

Done in #13740.

@anntzer anntzer closed this as completed Jul 4, 2019
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

8 participants