[Matplotlib-users] xkcd

2014-10-03 Thread Christophe Bal
Hello. I've only seen one way to use the xkcd feature. This uses a with statement. Is there another way to use the xkcd feature so as to easily switch between exact plot and trembling one ? Christophe BAL -- Meet PCI DSS

Re: [Matplotlib-users] xkcd

2014-10-03 Thread Paul Hobson
That's what the `with` statement allows you do. Say you have a function that does some plotting and returns a figure -- call it my_plot_func. You can do: fig1 = my_plot_func() fig1.savefig('normal1.png') with plt.xkcd(): fig2 = mu_plot_func() fig2.savefig('xkcd.png') fig2 = my_plot_fun

Re: [Matplotlib-users] xkcd

2014-10-04 Thread Phil Elson
Also note, you can just call plt.xkcd() and it will turn on the setting globally for that session. On 4 October 2014 00:11, Paul Hobson wrote: > That's what the `with` statement allows you do. > > Say you have a function that does some plotting and returns a figure -- > call it my_plot_func. > >

Re: [Matplotlib-users] XKCD style graphs?

2012-10-04 Thread Pierre Haessig
Hi Fernando, Le 04/10/2012 09:16, Fernando Perez a écrit : > This would make for an awesome couple of examples for the gallery, the > mathematica solutions look really pretty cool: > > http://mathematica.stackexchange.com/questions/11350/xkcd-style-graphs I've never used Mathematica so that it's p

Re: [Matplotlib-users] XKCD style graphs?

2012-10-04 Thread Damon McDougall
On Thu, Oct 4, 2012 at 10:02 AM, Pierre Haessig wrote: > Hi Fernando, > > Le 04/10/2012 09:16, Fernando Perez a écrit : >> This would make for an awesome couple of examples for the gallery, the >> mathematica solutions look really pretty cool: >> >> http://mathematica.stackexchange.com/questions/1

Re: [Matplotlib-users] XKCD style graphs?

2012-10-04 Thread Damon McDougall
On Thu, Oct 4, 2012 at 10:44 AM, Damon McDougall wrote: > On Thu, Oct 4, 2012 at 10:02 AM, Pierre Haessig > wrote: >> Hi Fernando, >> >> Le 04/10/2012 09:16, Fernando Perez a écrit : >>> This would make for an awesome couple of examples for the gallery, the >>> mathematica solutions look really p

Re: [Matplotlib-users] XKCD style graphs?

2012-10-04 Thread Phil Elson
Nice challenge Fernando! Damon, I love the solution! I do wonder whether we could do some quirky transform on the lines to achieve a similar result, rather than manipulating the data before plotting it. The benefit is that everything should then get randomly Xkcd-ed automatically - maybe I will sa

Re: [Matplotlib-users] XKCD style graphs?

2012-10-04 Thread Michael Droettboom
Yes -- this would be a great application for the path filtering infrastructure that matplotlib has. Mike On 10/04/2012 08:29 AM, Phil Elson wrote: > Nice challenge Fernando! > > Damon, I love the solution! I do wonder whether we could do some > quirky transform on the lines to achieve a similar

Re: [Matplotlib-users] XKCD style graphs?

2012-10-04 Thread Jason Grout
On 10/4/12 4:02 AM, Pierre Haessig wrote: > Hi Fernando, > > Le 04/10/2012 09:16, Fernando Perez a écrit : >> This would make for an awesome couple of examples for the gallery, the >> mathematica solutions look really pretty cool: >> >> http://mathematica.stackexchange.com/questions/11350/xkcd-styl

Re: [Matplotlib-users] XKCD style graphs?

2012-10-04 Thread Pierre Haessig
Le 04/10/2012 14:29, Phil Elson a écrit : > Damon, I love the solution! I do wonder whether we could do some > quirky transform on the lines to achieve a similar result, rather than > manipulating the data before plotting it. The benefit is that > everything should then get randomly Xkcd-ed automat

Re: [Matplotlib-users] XKCD style graphs?

2012-10-04 Thread Michael Droettboom
This is just too cool of an idea to pass up -- I'm going to see if I can put together a PR that does this using the C++ path filtering stuff so it would be available everywhere. Mike On 10/04/2012 10:11 AM, Michael Droettboom wrote: > Yes -- this would be a great application for the path filter

Re: [Matplotlib-users] XKCD style graphs?

2012-10-04 Thread Benjamin Root
On Thu, Oct 4, 2012 at 10:11 AM, Michael Droettboom wrote: > Yes -- this would be a great application for the path filtering > infrastructure that matplotlib has. > > Mike > > I agree with this idea. However, I don't think the code is set up to allow for user-defined path filters. Maybe an AGG

Re: [Matplotlib-users] XKCD style graphs?

2012-10-04 Thread Pierre Haessig
Le 04/10/2012 16:03, Jason Grout a écrit : > f@r means f(r) > > a~ImageConvolve~b means ImageConvolve(a,b) (~ treats an operator as infix) > > Table[..., {2}] means [... for i in range(2)] > > #+1& is a lambda function lambda x: x+1 > > So I think it goes something like: > > def xkcdDistort(p): >

Re: [Matplotlib-users] XKCD style graphs?

2012-10-04 Thread Pierre Haessig
Le 04/10/2012 16:11, Michael Droettboom a écrit : > Yes -- this would be a great application for the path filtering > infrastructure that matplotlib has. Sounds way cooler than post-processing a raster plot image ! I'm not aware of this path filtering infrastructure. I guess it's a deeply buried

Re: [Matplotlib-users] XKCD style graphs?

2012-10-04 Thread Jason Grout
On 10/4/12 9:11 AM, Michael Droettboom wrote: > Yes -- this would be a great application for the path filtering > infrastructure that matplotlib has. Is that the same as the path effects features, like http://matplotlib.org/examples/pylab_examples/patheffect_demo.html ? Thanks, Jason ---

Re: [Matplotlib-users] XKCD style graphs?

2012-10-04 Thread Benjamin Root
On Thu, Oct 4, 2012 at 10:39 AM, Pierre Haessig wrote: > Le 04/10/2012 16:11, Michael Droettboom a écrit : > > Yes -- this would be a great application for the path filtering > > infrastructure that matplotlib has. > Sounds way cooler than post-processing a raster plot image ! > > I'm not aware of

Re: [Matplotlib-users] XKCD style graphs?

2012-10-04 Thread Benjamin Root
On Thu, Oct 4, 2012 at 10:41 AM, Jason Grout wrote: > On 10/4/12 9:11 AM, Michael Droettboom wrote: > > Yes -- this would be a great application for the path filtering > > infrastructure that matplotlib has. > > > Is that the same as the path effects features, like > http://matplotlib.org/examples

Re: [Matplotlib-users] XKCD style graphs?

2012-10-04 Thread Damon McDougall
On Thu, Oct 4, 2012 at 3:35 PM, Pierre Haessig wrote: > Le 04/10/2012 16:03, Jason Grout a écrit : >> f@r means f(r) >> >> a~ImageConvolve~b means ImageConvolve(a,b) (~ treats an operator as infix) >> >> Table[..., {2}] means [... for i in range(2)] >> >> #+1& is a lambda function lambda x: x+1 >

Re: [Matplotlib-users] XKCD style graphs?

2012-10-04 Thread Michael Droettboom
On 10/04/2012 10:29 AM, Benjamin Root wrote: On Thu, Oct 4, 2012 at 10:11 AM, Michael Droettboom > wrote: Yes -- this would be a great application for the path filtering infrastructure that matplotlib has. Mike I agree with this idea. However, I don't t

Re: [Matplotlib-users] XKCD style graphs?

2012-10-04 Thread Pierre Haessig
Le 04/10/2012 16:54, Damon McDougall a écrit : > Adding Gaussian noise to each point on a function doesn't look nice. > That's why I produced a random function in Fourier space first. That > way, random functions still have some sense of smoothness. Mathematica code seems to use a Gaussian *smoothi

Re: [Matplotlib-users] XKCD style graphs?

2012-10-04 Thread Pierre Haessig
Le 04/10/2012 16:35, Pierre Haessig a écrit : > So I think this code indeed resamples the rastered plot image on a > shaken coordinate grid. I kind of understand that the noise on > coordinates is spatially smoothed by a 10px Gaussian Point Spread > Function (if I understand correctly...) I've impl

Re: [Matplotlib-users] XKCD style graphs?

2012-10-04 Thread Juergen Hasch
Here is my take on it as an IPython notebook, based on Damon's code: http://nbviewer.ipython.org/3835181/ I took the engineering approach and filtered the random function instead of doing some fft/ifft magic. Also, X and Y of the functions are affected now, giving them a more "natural" look in t

Re: [Matplotlib-users] XKCD style graphs?

2012-10-04 Thread Damon McDougall
On Thu, Oct 4, 2012 at 10:09 PM, Juergen Hasch wrote: > Here is my take on it as an IPython notebook, based on Damon's code: > http://nbviewer.ipython.org/3835181/ > > I took the engineering approach and filtered the random function instead of > doing some fft/ifft magic. > Also, X and Y of the f

Re: [Matplotlib-users] XKCD style graphs?

2012-10-04 Thread Fernando Perez
Sweet! That should *defiintely* go into the mpl gallery, and honestly I'd love for it to be cleaned up enough to be usable to style generically any plot, much like the mathematica code I linked to earlier does. It would be a beautiful demonstration of matplotlib's capabilities, and furthermore, I

Re: [Matplotlib-users] XKCD style graphs?

2012-10-04 Thread Michael Droettboom
I've put up a PR adding this "sketchy" line drawing as a path filter. This makes it work with almost anything that matplotlib draws. https://github.com/matplotlib/matplotlib/pull/1329 Mike On 10/04/2012 06:06 PM, Fernando Perez wrote: > Sweet! That should *defiintely* go into the mpl gallery,

Re: [Matplotlib-users] XKCD style graphs?

2012-10-05 Thread Matthias BUSSONNIER
Le 4 oct. 2012 à 23:09, Juergen Hasch a écrit : > Here is my take on it as an IPython notebook, based on Damon's code: > http://nbviewer.ipython.org/3835181/ > > I took the engineering approach and filtered the random function instead of > doing some fft/ifft magic. > Also, X and Y of the funct

Re: [Matplotlib-users] XKCD style graphs?

2012-10-05 Thread Damon McDougall
On Fri, Oct 5, 2012 at 10:13 AM, Matthias BUSSONNIER wrote: > > Le 4 oct. 2012 à 23:09, Juergen Hasch a écrit : > >> Here is my take on it as an IPython notebook, based on Damon's code: >> http://nbviewer.ipython.org/3835181/ >> >> I took the engineering approach and filtered the random function i

Re: [Matplotlib-users] XKCD style graphs?

2012-10-05 Thread Jason Grout
On 10/4/12 2:16 AM, Fernando Perez wrote: > This would make for an awesome couple of examples for the gallery, the > mathematica solutions look really pretty cool: > > http://mathematica.stackexchange.com/questions/11350/xkcd-style-graphs > > The matlab and R version not quite so much, still for re

Re: [Matplotlib-users] XKCD style graphs?

2012-10-11 Thread Juergen Hasch
Am 05.10.2012 11:13, schrieb Matthias BUSSONNIER: > > Le 4 oct. 2012 à 23:09, Juergen Hasch a écrit : > >> Here is my take on it as an IPython notebook, based on Damon's code: >> http://nbviewer.ipython.org/3835181/ >> >> I took the engineering approach and filtered the random function instead of