I've never used matlab (and hope never to have to). But I've been using pyplot api for mpl for quite a while. Is there any good reason to move to the "native" mpl api and drop pyplot? I ask because as I understand, pyplot is intended as a matlab workalike, and since I never learned matlab I have no need for that crutch. OTOH, I'm quite used to the pyplot api at this point.
I wrote up my answer to this question on stackoverflow once: https://stackoverflow.com/questions/19895262/when-to-use-the-matplotlib-pyplot-class-and-when-to-use-the-plot-object-matplot/21004357#21004357 Others may have different opinions or variations on the theme, but this is how I look at the issue. It is also the reason why I don't want to deprecate pylab (but do want to keep it out of examples). Cheers! Ben Root On Wed, Apr 30, 2014 at 7:49 AM, Neal Becker <ndb...@gm...> wrote: > I've never used matlab (and hope never to have to). But I've been using > pyplot > api for mpl for quite a while. > > Is there any good reason to move to the "native" mpl api and drop pyplot? > I ask > because as I understand, pyplot is intended as a matlab workalike, and > since I > never learned matlab I have no need for that crutch. OTOH, I'm quite used > to > the pyplot api at this point. > > > > ------------------------------------------------------------------------------ > "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE > Instantly run your Selenium tests across 300+ browser/OS combos. Get > unparalleled scalability from the best Selenium testing platform available. > Simple to use. Nothing to install. Get started now for free." > http://p.sf.net/sfu/SauceLabs > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >
The only pyplot function I let myself use is plt.subplots() to quickly create the Figure and Axes objects. From that point on, I operate on those objects directly. Frankly, it reads almost exactly like pyplot code, but it is a *lot* more clear what's going on. On Wed, Apr 30, 2014 at 4:49 AM, Neal Becker <ndb...@gm...> wrote: > I've never used matlab (and hope never to have to). But I've been using > pyplot > api for mpl for quite a while. > > Is there any good reason to move to the "native" mpl api and drop pyplot? > I ask > because as I understand, pyplot is intended as a matlab workalike, and > since I > never learned matlab I have no need for that crutch. OTOH, I'm quite used > to > the pyplot api at this point. > > > > ------------------------------------------------------------------------------ > "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE > Instantly run your Selenium tests across 300+ browser/OS combos. Get > unparalleled scalability from the best Selenium testing platform available. > Simple to use. Nothing to install. Get started now for free." > http://p.sf.net/sfu/SauceLabs > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >
Paul Hobson wrote: > The only pyplot function I let myself use is plt.subplots() to quickly > create the Figure and Axes objects. From that point on, I operate on those > objects directly. Frankly, it reads almost exactly like pyplot code, but it > is a *lot* more clear what's going on. > ... Actually this is going to be harder than I thought. Looking around for some examples of API not using pyplot I'm not turning up much. If I look at http://matplotlib.org/api/index.html I quickly find myself staring at pyplot docs, and if I look at a few http://matplotlib.org/examples/index.html I see pyplot examples. Where would I find non-pyplot examples and docs?
99.9% of the time I am using pyplot, as it usually does what I want without me having to understand an api. I don't care so much if pyplot agrees with matlab or not, but it should be something easy that new users can pick up quickly. Best, -Michiel -------------------------------------------- On Wed, 4/30/14, Neal Becker <ndb...@gm...> wrote: Subject: [Matplotlib-users] Which api to learn? To: mat...@li... Date: Wednesday, April 30, 2014, 7:49 AM I've never used matlab (and hope never to have to). But I've been using pyplot api for mpl for quite a while. Is there any good reason to move to the "native" mpl api and drop pyplot? I ask because as I understand, pyplot is intended as a matlab workalike, and since I never learned matlab I have no need for that crutch. OTOH, I'm quite used to the pyplot api at this point. ------------------------------------------------------------------------------ "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE Instantly run your Selenium tests across 300+ browser/OS combos. Get unparalleled scalability from the best Selenium testing platform available. Simple to use. Nothing to install. Get started now for free." http://p.sf.net/sfu/SauceLabs _______________________________________________ Matplotlib-users mailing list Mat...@li... https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Hi Neal, I always followed what has been written here: http://matplotlib.org/faq/usage_faq.html#matplotlib-pylab-and-pyplot-how-are-they-related And they said, ------------------ Matplotlib, pylab, and pyplot: how are they related? Matplotlib is the whole package; pylab is a module in matplotlib that gets installed alongside matplotlib; andmatplotlib.pyplot is a module in matplotlib. Pyplot provides the state-machine interface to the underlying plotting library in matplotlib. This means that figures and axes are implicitly and automatically created to achieve the desired plot. For example, calling plot from pyplot will automatically create the necessary figure and axes to achieve the desired plot. Setting a title will then automatically set that title to the current axes object: import matplotlib.pyplot as plt plt.plot(range(10), range(10)) plt.title("Simple Plot") plt.show() Pylab combines the pyplot functionality (for plotting) with the numpy functionality (for mathematics and for working with arrays) in a single namespace, making that namespace (or environment) even more MATLAB-like. For example, one can call the sin and cos functions just like you could in MATLAB, as well as having all the features of pyplot. The pyplot interface is generally preferred for non-interactive plotting (i.e., scripting). The pylab interface is convenient for interactive calculations and plotting, as it minimizes typing. Note that this is what you get if you use the ipython shell with the -pylab option, which imports everything from pylab and makes plotting fully interactive. ------------------ -Shawn On Thu, May 1, 2014 at 2:16 AM, Michiel de Hoon <mjl...@ya...> wrote: > 99.9% of the time I am using pyplot, as it usually does what I want without me having to understand an api. > I don't care so much if pyplot agrees with matlab or not, but it should be something easy that new users can pick up quickly. > > Best, > -Michiel > > -------------------------------------------- > On Wed, 4/30/14, Neal Becker <ndb...@gm...> wrote: > > Subject: [Matplotlib-users] Which api to learn? > To: mat...@li... > Date: Wednesday, April 30, 2014, 7:49 AM > > I've never used matlab (and hope > never to have to). But I've been using pyplot > api for mpl for quite a while. > > Is there any good reason to move to the "native" mpl api and > drop pyplot? I ask > because as I understand, pyplot is intended as a matlab > workalike, and since I > never learned matlab I have no need for that crutch. > OTOH, I'm quite used to > the pyplot api at this point. > > > ------------------------------------------------------------------------------ > "Accelerate Dev Cycles with Automated Cross-Browser Testing > - For FREE > Instantly run your Selenium tests across 300+ browser/OS > combos. Get > unparalleled scalability from the best Selenium testing > platform available. > Simple to use. Nothing to install. Get started now for > free." > http://p.sf.net/sfu/SauceLabs > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > ------------------------------------------------------------------------------ > "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE > Instantly run your Selenium tests across 300+ browser/OS combos. Get > unparalleled scalability from the best Selenium testing platform available. > Simple to use. Nothing to install. Get started now for free." > http://p.sf.net/sfu/SauceLabs > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Yuxiang "Shawn" Wang Gerling Research Lab University of Virginia yw...@vi... +1 (434) 284-0836 https://sites.google.com/a/virginia.edu/yw5aj/
""" The pyplot interface is generally preferred for non-interactive plotting (i.e., scripting). The pylab interface is convenient for interactive calculations and plotting, as it minimizes typing. Note that this is what you get if you use the ipython shell with the -pylab option, which imports everything from pylab and makes plotting fully interactive. """ Gotta remember to update this paragraph... the -pylab option has been long deprecated, and is supposedly about to be removed in an upcoming release of ipython. Ben Root On Thu, May 1, 2014 at 10:38 AM, Yuxiang Wang <yw...@vi...> wrote: > Hi Neal, > > I always followed what has been written here: > > > http://matplotlib.org/faq/usage_faq.html#matplotlib-pylab-and-pyplot-how-are-they-related > > And they said, > > ------------------ > Matplotlib, pylab, and pyplot: how are they related? > > Matplotlib is the whole package; pylab is a module in matplotlib that > gets installed alongside matplotlib; andmatplotlib.pyplot is a module > in matplotlib. > > Pyplot provides the state-machine interface to the underlying plotting > library in matplotlib. This means that figures and axes are implicitly > and automatically created to achieve the desired plot. For example, > calling plot from pyplot will automatically create the necessary > figure and axes to achieve the desired plot. Setting a title will then > automatically set that title to the current axes object: > > import matplotlib.pyplot as plt > > plt.plot(range(10), range(10)) > plt.title("Simple Plot") > plt.show() > > Pylab combines the pyplot functionality (for plotting) with the numpy > functionality (for mathematics and for working with arrays) in a > single namespace, making that namespace (or environment) even more > MATLAB-like. For example, one can call the sin and cos functions just > like you could in MATLAB, as well as having all the features of > pyplot. > > The pyplot interface is generally preferred for non-interactive > plotting (i.e., scripting). The pylab interface is convenient for > interactive calculations and plotting, as it minimizes typing. Note > that this is what you get if you use the ipython shell with the -pylab > option, which imports everything from pylab and makes plotting fully > interactive. > ------------------ > > > -Shawn > > On Thu, May 1, 2014 at 2:16 AM, Michiel de Hoon <mjl...@ya...> > wrote: > > 99.9% of the time I am using pyplot, as it usually does what I want > without me having to understand an api. > > I don't care so much if pyplot agrees with matlab or not, but it should > be something easy that new users can pick up quickly. > > > > Best, > > -Michiel > > > > -------------------------------------------- > > On Wed, 4/30/14, Neal Becker <ndb...@gm...> wrote: > > > > Subject: [Matplotlib-users] Which api to learn? > > To: mat...@li... > > Date: Wednesday, April 30, 2014, 7:49 AM > > > > I've never used matlab (and hope > > never to have to). But I've been using pyplot > > api for mpl for quite a while. > > > > Is there any good reason to move to the "native" mpl api and > > drop pyplot? I ask > > because as I understand, pyplot is intended as a matlab > > workalike, and since I > > never learned matlab I have no need for that crutch. > > OTOH, I'm quite used to > > the pyplot api at this point. > > > > > > > ------------------------------------------------------------------------------ > > "Accelerate Dev Cycles with Automated Cross-Browser Testing > > - For FREE > > Instantly run your Selenium tests across 300+ browser/OS > > combos. Get > > unparalleled scalability from the best Selenium testing > > platform available. > > Simple to use. Nothing to install. Get started now for > > free." > > http://p.sf.net/sfu/SauceLabs > > _______________________________________________ > > Matplotlib-users mailing list > > Mat...@li... > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > > > ------------------------------------------------------------------------------ > > "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE > > Instantly run your Selenium tests across 300+ browser/OS combos. Get > > unparalleled scalability from the best Selenium testing platform > available. > > Simple to use. Nothing to install. Get started now for free." > > http://p.sf.net/sfu/SauceLabs > > _______________________________________________ > > Matplotlib-users mailing list > > Mat...@li... > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > -- > Yuxiang "Shawn" Wang > Gerling Research Lab > University of Virginia > yw...@vi... > +1 (434) 284-0836 > https://sites.google.com/a/virginia.edu/yw5aj/ > > > ------------------------------------------------------------------------------ > "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE > Instantly run your Selenium tests across 300+ browser/OS combos. Get > unparalleled scalability from the best Selenium testing platform available. > Simple to use. Nothing to install. Get started now for free." > http://p.sf.net/sfu/SauceLabs > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >