# ANN: mpltools 0.1 release

Your suggestion would be consistent with how errorbar() works, I think.

Ben Root

···

On Fri, Jul 13, 2012 at 7:01 PM, Damon McDougall <damon.mcdougall@…287…> wrote:

On Wed, Jul 11, 2012 at 08:33:21PM -0400, Tony Yu wrote:

On Wed, Jul 11, 2012 at 2:28 PM, Benjamin Root <ben.root@…1304…> wrote:

On Wed, Jul 11, 2012 at 11:23 AM, John Hunter <jdh2358@…287…> wrote:

On Wed, Jul 11, 2012 at 10:09 AM, Damon McDougall < > > > >> damon.mcdougall@…287…> wrote:

Well, as Ben said, that error fill plot is neato! It doesn’t look too

complicated, either. I’d be more than happy to port it over later today

when I get bored of typing up my thesis. It’ll probably only take me

If nobody is opposed to this idea, I’ll go ahead and submit a PR this

evening (British Summer (hah!) Time).

While it is a nice graph, I am not sure that the use case is common

enough to justify a new plotting method. One can get the same result with:

In [68]: x = np.linspace(0, 2 * np.pi)

In [69]: y_sin = np.sin(x)

In [70]: err = np.concatenate([y_sin + 0.2, y_sin[::-1] - 0.2])

In [71]: plot(x, y_sin)

Out[71]: [<matplotlib.lines.Line2D object at 0x96959ec>]

In [72]: fill_between(np.concatenate([x, x[::-1]]), err,

facecolor=‘red’, alpha=0.5)

Out[72]: <matplotlib.collections.PolyCollection object at 0x962758c>

Admittedly the [::-1] thing is a bit counter-intuitive, but rather than

adding a new plotting method, perhaps we would be better off with a helper

method to create the xs and ys for fill_between

xs, ys = mlab.pad_line(x, y, 0.2)

fill_between(xs, ys)

JDH

I could definitely agree with a pad_line() function. We might want to

revisit the issue of how much visibility the mlab module should get in the

documentation (it currently doesn’t get much at all). My whole take on

mlab was that it was a left-over from the days of working around issues in

NumPy and SciPy and that it was being slowly phased out. As for other

possible locations, cbook feels like it is more for the devs than for the

users, and adding it to pyplot would render the whole purpose of creating

this function as opposed to errorfill moot.

be nice to mirror the errorbar() functionality to allow not only a constant

error, but also a N, Nx1, or 2xN array of +/- error. (note that errorbar()

for the 2xN array case does -row1 and +row2).

Damon: it sounds like you’re volunteering to submit a PR to add this

function

Here’s the relevant bit (which should already handle the cases Ben mentions

above):

https://github.com/tonysyu/mpltools/blob/master/mpltools/special/errorfill.py#L54

Great. I’ve basically done this. I have one suggestion, though. In the

case where len(zerr) == 2, you are setting

zmin, zmax = zerr

I think it makes more sense to set

zmin, zmax = z - zerr[0], z + zerr[1]

What do you think?

Tony, is there a way to “switch” styles rather than chain them. Eg, if I do:

import mpltools.style as style

style.use(‘ieee.transaction’)

…make_a_plot_…

style.use(‘ggplot’)

. …make_a_plot_…

I seem to get the chained behavior of the second style updating the first. I’d like to use this in a demo context where I can illustrate the styles separately, so it would be nice to go back to the defaults.

Interestingly, I tried to do:

import matplotlib

matplotlib.rc_file_defaults()

plt.close(‘all’)

hist(rand(10000), 100)

but that simply stopped figures from raising all together (I don’t think this is related to mpltools, but to something funny going on on my system).

So in summary, it would be nice to be able to do something like:

style.use(‘default’)

or:

style.reset()

which would take you back to a clean slate.

···

On Tue, Jul 10, 2012 at 11:58 AM, Tony Yu <tsyu80@…287…> wrote:

Announcement: mpltools 0.1

==========================

mpltools is a package of tools for matplotlib. For the most part, these tools are only loosely-connected in functionality, but there are two that may prove particularly useful:

Styles and plot2rst

I’ve been using plt.rcdefaults() for that purpose. Does that work for you?

-Tony

···

On Mon, Jul 16, 2012 at 3:07 PM, John Hunter <jdh2358@…287…> wrote:

On Tue, Jul 10, 2012 at 11:58 AM, Tony Yu <tsyu80@…287…> wrote:

Announcement: mpltools 0.1

==========================

mpltools is a package of tools for matplotlib. For the most part, these tools are only loosely-connected in functionality, but there are two that may prove particularly useful:

Styles and plot2rst

Tony, is there a way to “switch” styles rather than chain them. Eg, if I do:

import mpltools.style as style

style.use(‘ieee.transaction’)

…make_a_plot_…

style.use(‘ggplot’)

. …make_a_plot_…

I seem to get the chained behavior of the second style updating the first. I’d like to use this in a demo context where I can illustrate the styles separately, so it would be nice to go back to the defaults.

Interestingly, I tried to do:

import matplotlib

matplotlib.rc_file_defaults()

plt.close(‘all’)

hist(rand(10000), 100)

but that simply stopped figures from raising all together (I don’t think this is related to mpltools, but to something funny going on on my system).

So in summary, it would be nice to be able to do something like:

style.use(‘default’)

or:

style.reset()

which would take you back to a clean slate.

Err, maybe I read your question wrong. Were you just suggesting that I wrap `matplotlib.rc_file_defaults()` in a new function called `style.reset()`, or were you suggesting a function that does something different than `rc_file_defaults`?

-Tony

···

On Mon, Jul 16, 2012 at 6:06 PM, Tony Yu <tsyu80@…287…> wrote:

On Mon, Jul 16, 2012 at 3:07 PM, John Hunter <jdh2358@…287…> wrote:

On Tue, Jul 10, 2012 at 11:58 AM, Tony Yu <tsyu80@…287…> wrote:

Announcement: mpltools 0.1

==========================

mpltools is a package of tools for matplotlib. For the most part, these tools are only loosely-connected in functionality, but there are two that may prove particularly useful:

Styles and plot2rst

Tony, is there a way to “switch” styles rather than chain them. Eg, if I do:

import mpltools.style as style

style.use(‘ieee.transaction’)

…make_a_plot_…

style.use(‘ggplot’)

. …make_a_plot_…

I seem to get the chained behavior of the second style updating the first. I’d like to use this in a demo context where I can illustrate the styles separately, so it would be nice to go back to the defaults.

Interestingly, I tried to do:

import matplotlib

matplotlib.rc_file_defaults()

plt.close(‘all’)

hist(rand(10000), 100)

but that simply stopped figures from raising all together (I don’t think this is related to mpltools, but to something funny going on on my system).

So in summary, it would be nice to be able to do something like:

style.use(‘default’)

or:

style.reset()

which would take you back to a clean slate.

I’ve been using plt.rcdefaults() for that purpose. Does that work for you?

-Tony

What about adding a property to the existing errorbar to let someone
change it to the filled version? This could also, potentially, be
extended with other types of error bars if the need arises.

-Todd

···

On Wed, Jul 11, 2012 at 5:23 PM, John Hunter <jdh2358@...287...> wrote:

On Wed, Jul 11, 2012 at 10:09 AM, Damon McDougall > <damon.mcdougall@...287...> wrote:

Well, as Ben said, that error fill plot is neato! It doesn't look too
complicated, either. I'd be more than happy to port it over later today
when I get bored of typing up my thesis. It'll probably only take me

If nobody is opposed to this idea, I'll go ahead and submit a PR this
evening (British Summer (hah!) Time).

While it is a nice graph, I am not sure that the use case is common enough
to justify a new plotting method. One can get the same result with:

In [68]: x = np.linspace(0, 2 * np.pi)

In [69]: y_sin = np.sin(x)

In [70]: err = np.concatenate([y_sin + 0.2, y_sin[::-1] - 0.2])

In [71]: plot(x, y_sin)
Out[71]: [<matplotlib.lines.Line2D object at 0x96959ec>]

In [72]: fill_between(np.concatenate([x, x[::-1]]), err, facecolor='red',
alpha=0.5)
Out[72]: <matplotlib.collections.PolyCollection object at 0x962758c>

Admittedly the [::-1] thing is a bit counter-intuitive, but rather than
adding a new plotting method, perhaps we would be better off with a helper
method to create the xs and ys for fill_between

xs, ys = mlab.pad_line(x, y, 0.2)
fill_between(xs, ys)

JDH

Intriguing idea. I am actually quite comfortable with that.

Ben Root

···

On Tue, Jul 17, 2012 at 6:25 AM, todd rme <toddrme2178@…287…> wrote:

On Wed, Jul 11, 2012 at 5:23 PM, John Hunter <jdh2358@…287…> wrote:

On Wed, Jul 11, 2012 at 10:09 AM, Damon McDougall > > > <damon.mcdougall@…1003…7…> wrote:

Well, as Ben said, that error fill plot is neato! It doesn’t look too

complicated, either. I’d be more than happy to port it over later today

when I get bored of typing up my thesis. It’ll probably only take me

If nobody is opposed to this idea, I’ll go ahead and submit a PR this

evening (British Summer (hah!) Time).

While it is a nice graph, I am not sure that the use case is common enough

to justify a new plotting method. One can get the same result with:

In [68]: x = np.linspace(0, 2 * np.pi)

In [69]: y_sin = np.sin(x)

In [70]: err = np.concatenate([y_sin + 0.2, y_sin[::-1] - 0.2])

In [71]: plot(x, y_sin)

Out[71]: [<matplotlib.lines.Line2D object at 0x96959ec>]

In [72]: fill_between(np.concatenate([x, x[::-1]]), err, facecolor=‘red’,

alpha=0.5)

Out[72]: <matplotlib.collections.PolyCollection object at 0x962758c>

Admittedly the [::-1] thing is a bit counter-intuitive, but rather than

adding a new plotting method, perhaps we would be better off with a helper

method to create the xs and ys for fill_between

xs, ys = mlab.pad_line(x, y, 0.2)

fill_between(xs, ys)

JDH

What about adding a property to the existing errorbar to let someone

change it to the filled version? This could also, potentially, be

extended with other types of error bars if the need arises.

-Todd

> >
> >
> >>
> >> Well, as Ben said, that error fill plot is neato! It doesn't look too
> >> complicated, either. I'd be more than happy to port it over later today
> >> when I get bored of typing up my thesis. It'll probably only take me
> >>
> >> If nobody is opposed to this idea, I'll go ahead and submit a PR this
> >> evening (British Summer (hah!) Time).
> >
> >
> >
> > While it is a nice graph, I am not sure that the use case is common
> enough
> > to justify a new plotting method. One can get the same result with:
> >
> >
> > In [68]: x = np.linspace(0, 2 * np.pi)
> >
> > In [69]: y_sin = np.sin(x)
> >
> > In [70]: err = np.concatenate([y_sin + 0.2, y_sin[::-1] - 0.2])
> >
> > In [71]: plot(x, y_sin)
> > Out[71]: [<matplotlib.lines.Line2D object at 0x96959ec>]
> >
> > In [72]: fill_between(np.concatenate([x, x[::-1]]), err,
> facecolor='red',
> > alpha=0.5)
> > Out[72]: <matplotlib.collections.PolyCollection object at 0x962758c>
> >
> > Admittedly the [::-1] thing is a bit counter-intuitive, but rather than
> > adding a new plotting method, perhaps we would be better off with a
> helper
> > method to create the xs and ys for fill_between
> >
> > xs, ys = mlab.pad_line(x, y, 0.2)
> > fill_between(xs, ys)
> >
> > JDH
>
> What about adding a property to the existing errorbar to let someone
> change it to the filled version? This could also, potentially, be
> extended with other types of error bars if the need arises.
>
> -Todd
>

Intriguing idea. I am actually quite comfortable with that.

I like this idea, too.

···

On Tue, Jul 17, 2012 at 08:21:50AM -0500, Benjamin Root wrote:

On Tue, Jul 17, 2012 at 6:25 AM, todd rme <toddrme2178@...287...> wrote:
> On Wed, Jul 11, 2012 at 5:23 PM, John Hunter <jdh2358@...287...> wrote:
> > On Wed, Jul 11, 2012 at 10:09 AM, Damon McDougall > > > <damon.mcdougall@...287...> wrote:

Ben Root

--
Damon McDougall
http://damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom