From: Tony Yu <ts...@gm...> - 2012-07-11 17:12:23
|
On Wed, Jul 11, 2012 at 11:27 AM, Benjamin Root <ben...@ou...> wrote: > > > On Wed, Jul 11, 2012 at 11:23 AM, John Hunter <jd...@gm...> wrote: > >> >> >> On Wed, Jul 11, 2012 at 10:09 AM, Damon McDougall < >> dam...@gm...> 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 >>> about 30 minutes. >>> >>> 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 >> > > At the very least, it should be added to the gallery. Also, one thing > that might (or might not) get in the way of getting merged into mainline > mpl is how well it interacts with legends. What does it produce in the > legend? > > Ben Root > > As I said before, it is a really simple function: I wrote `errorfill` just to get an interface that is somewhat similar to `errorbar`. I tend to think that the Axes object is a bit bloated, so I'm inclined to agree that it might be best leave it out of matplotlib-proper. +1 on the gallery, though. Ben: Good point about the legend-interaction. I just added a fix on github; here's the result: http://tonysyu.github.com/mpltools/auto_examples/special/plot_errorfill.html Cheers, -Tony |