Re: [Matplotlib-users] who (F/OSS science) uses matplotlib?
On Wed, Jun 6, 2012 at 8:01 AM, Guillaume Gay wrote: > Le 05/06/2012 16:25, Tom Dimiduk a écrit : >> Is any of this stuff I should be looking to upstream or split off into >> the start of a scientific imaging library for python? > Have you had a look at skimage https://github.com/scikits-image ? > > > BTW I uses matplotlib (and the whole pylab suite) in my projects for all > the visualisation. > A (peer reviewed published) example here: > https://github.com/Kinetochore-segregation > > Best > > Guillaume The Spyder (http://code.google.com/p/spyderlib/) python-based matlab clone uses matplotlib for plotting. Python(X,Y) (http://code.google.com/p/pythonxy/) is an integrated windows python release that includes a ton of science, engineering, and mathematics-oriented python packages, including matplotlib. Numpy uses small bits of matplotlib when building the documentation, but I don't know if that counts (I think it may even use it for building matplotlib-related parts of the documentation, in which case it really doesn't count). I know someone is working on a pure python backend for the Cantor advanced mathematics software (http://edu.kde.org/cantor/). The project only started recently, however (see http://blog.filipesaraiva.info/?p=779 ). There is also already a sage backend for Cantor, which of course uses matplotlib for plotting because that is what sage uses. -Todd -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] scatter plot with constant x
Hey! :o) This should be simple, but i cant manage: I need to plot many dots with the same x, like plt.plot([3,3,3,3],[60,80,120,180],'+',markersize=8,mec='k') The array for x values is silly, especially since the number of y values may be rather large. Is there a way to enter a constant there? Cheers to you all! Ulli -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] scatter plot with constant x
On Tue, Jun 5, 2012 at 11:53 AM, Ulrich vor dem Esche < ulrich.es...@googlemail.com> wrote: > Hey! :o) > This should be simple, but i cant manage: I need to plot many dots with > the same x, like > > plt.plot([3,3,3,3],[60,80,120,180],'+',markersize=8,mec='k') > > The array for x values is silly, especially since the number of y values > may be rather large. Is there a way to enter a constant there? > > Cheers to you all! > Ulli > > No, but you can do this: plt.plot([3] * 4, [60, 80, 120, 180], ...) Does that help? Ben Root -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] scatter plot with constant x
> ... > No, but you can do this: > > plt.plot([3] * 4, [60, 80, 120, 180], ...) This started from a simple enough question, but it got me thinking about what the fastest way to do this is (in case you have HUGE arrays, or many loops over them). This may be old news to some of you, but I thought it was interesting: In ipython --pylab In [1]: %timeit l=[3]*1 1 loops, best of 3: 53.3 us per loop In [2]: %timeit l=np.zeros(1)+3 1 loops, best of 3: 26.9 us per loop In [3]: %timeit l=np.ones(1)*3 1 loops, best of 3: 32.9 us per loop In [4]: %timeit l=(np.zeros(1)+3).repeat(1) 1 loops, best of 3: 87.4 us per loop In [5]: %timeit l=np.zeros(1);l[:]=3 1 loops, best of 3: 21.6 us per loop In [6]: %timeit l=np.zeros(1,dtype=np.uint8);l[:]=3 10 loops, best of 3: 13.9 us per loop Using int16, int32, float32 get progressively slower to the default float64 case listed on line [5], changing the datatype in other methods doesn't result in nearly as large a speed up as it does in the last case. Ben's method is probably the most elegant for small arrays, but does any one else have a faster way to do this? (I'm assuming no use of blitz, inline C, f2py, but if you think you can do it faster in one of those, show me the way). Sorry, maybe this is more appropriate on the numpy list. Ethan -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] scatter plot with constant x
On 06/06/2012 12:42 PM, Ethan Gutmann wrote: >> ... >> No, but you can do this: >> >> plt.plot([3] * 4, [60, 80, 120, 180], ...) > Using int16, int32, float32 get progressively slower to the default float64 > case listed on line [5], changing the datatype in other methods doesn't > result in nearly as large a speed up as it does in the last case. > Interesting result. Note, however, that matplotlib will eventually turn all data arrays into float64 at rendering time, so any speed advantage to using integers will be lost by the subsequent conversion, I suspect. Mike -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] scatter plot with constant x
On Jun 6, 2012, at 10:49 AM, Michael Droettboom wrote: > Interesting result. Note, however, that matplotlib will eventually turn > all data arrays into float64 at rendering time, so any speed advantage > to using integers will be lost by the subsequent conversion, I suspect. I don't think it does if you pass uint8 to imshow, but otherwise you might be right. ethan -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] scatter plot with constant x
On 06/06/2012 12:54 PM, Ethan Gutmann wrote: > On Jun 6, 2012, at 10:49 AM, Michael Droettboom wrote: >> Interesting result. Note, however, that matplotlib will eventually turn >> all data arrays into float64 at rendering time, so any speed advantage >> to using integers will be lost by the subsequent conversion, I suspect. > I don't think it does if you pass uint8 to imshow, but otherwise you might be > right. Sure. I was referring to scatter here. With imshow, of course, everything is ultimately turned into 8-bits-per-plane rgba. Mike -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] scatter plot with constant x
On 06/06/2012 06:42 AM, Ethan Gutmann wrote: >> ... >> No, but you can do this: >> >> plt.plot([3] * 4, [60, 80, 120, 180], ...) > > This started from a simple enough question, but it got me thinking about what > the fastest way to do this is (in case you have HUGE arrays, or many loops > over them). This may be old news to some of you, but I thought it was > interesting: > > In ipython --pylab > > In [1]: %timeit l=[3]*1 > 1 loops, best of 3: 53.3 us per loop > > In [2]: %timeit l=np.zeros(1)+3 > 1 loops, best of 3: 26.9 us per loop > > In [3]: %timeit l=np.ones(1)*3 > 1 loops, best of 3: 32.9 us per loop > > In [4]: %timeit l=(np.zeros(1)+3).repeat(1) > 1 loops, best of 3: 87.4 us per loop > > In [5]: %timeit l=np.zeros(1);l[:]=3 > 1 loops, best of 3: 21.6 us per loop > > In [6]: %timeit l=np.zeros(1,dtype=np.uint8);l[:]=3 > 10 loops, best of 3: 13.9 us per loop > > Using int16, int32, float32 get progressively slower to the default float64 > case listed on line [5], changing the datatype in other methods doesn't > result in nearly as large a speed up as it does in the last case. > > Ben's method is probably the most elegant for small arrays, but does any one > else have a faster way to do this? (I'm assuming no use of blitz, inline C, > f2py, but if you think you can do it faster in one of those, show me the way). > Since we end up needing float64 anyway: In [3]: %timeit l=np.empty(1,dtype=np.float64); l.fill(3) 10 loops, best of 3: 14.1 us per loop In [4]: %timeit l=np.zeros(1,dtype=np.float64);l[:]=3 1 loops, best of 3: 26.6 us per loop Eric > Sorry, maybe this is more appropriate on the numpy list. > > Ethan > > > -- > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] scatter plot with constant x
On Jun 6, 2012, at 11:41 AM, Eric Firing wrote: > Since we end up needing float64 anyway: > > In [3]: %timeit l=np.empty(1,dtype=np.float64); l.fill(3) > 10 loops, best of 3: 14.1 us per loop nice, fill and empty seem to be responsible for about half the speed up each, good tools to know about. -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] scatter plot with constant x
> From: Eric Firing [mailto:efir...@hawaii.edu] > Sent: Wednesday, June 06, 2012 13:41 > To: matplotlib-users@lists.sourceforge.net > Subject: Re: [Matplotlib-users] scatter plot with constant x > > On 06/06/2012 06:42 AM, Ethan Gutmann wrote: > >> ... > >> No, but you can do this: > >> > >> plt.plot([3] * 4, [60, 80, 120, 180], ...) > > > > This started from a simple enough question, but it got me > thinking about what the fastest way to do this is (in case > you have HUGE arrays, or many loops over them). [...] > Since we end up needing float64 anyway: > > In [3]: %timeit l=np.empty(1,dtype=np.float64); l.fill(3) > 10 loops, best of 3: 14.1 us per loop > > In [4]: %timeit l=np.zeros(1,dtype=np.float64);l[:]=3 > 1 loops, best of 3: 26.6 us per loop > > Eric Numpy's as_strided came to mind; it can make a large array that's really a view of a one-element array: In [1]: as_strided = np.lib.stride_tricks.as_strided In [2]: s = as_strided(np.array([3], dtype=np.float64), shape=(1,), ...: strides=(0,)) In [3]: s[0] = 4 In [4]: s[] # all elements share data Out[4]: 4.0 It's somewhat slower to create the base array and the view than to create and fill a 1-element array: In [5]: %timeit l = np.empty(1, dtype=np.float64); l.fill(3) 10 loops, best of 3: 10.1 us per loop In [6]: %timeit s = as_strided(np.array([3], dtype=np.float64), shape=(1,), strides=(0,)) # line broken for email 1 loops, best of 3: 21.6 us per loop However, once created, its contents may be changed much more quickly: In [7]: l = np.empty(1, dtype=np.float64) In [8]: %timeit l.fill(3) 10 loops, best of 3: 7.71 us per loop In [9]: %timeit s[0] = 3 1000 loops, best of 3: 116 ns per loop Numpy's broadcast_arrays uses as_strided under the hood. Code could look like: x, y = np.broadcast_arrays(3, [60, 80, 120, 180]) plt.plot(x, y, '+') x[0] = 21 # new x for all samples plt.plot(x, y, 'x') -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] ymax
Hi, for this script: from pylab import * fig = figure() ax = fig.add_subplot(111) ax.axis('equal') x = linspace(-2, 3, 50) ax.plot(x, sin(x)) show() - If I try to get ymax with ax.get_ylim(), i obtain 1.0 whereas I observe it is 2.0. How can I obtain 2.0 for ymax ? Thanks. Kamel -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] ymax
On Wed, Jun 6, 2012 at 3:32 PM, kamel maths wrote: > Hi, > > for this script: > > from pylab import * > > fig = figure() > ax = fig.add_subplot(111) > ax.axis('equal') > > x = linspace(-2, 3, 50) > ax.plot(x, sin(x)) > > show() > - > If I try to get ymax with ax.get_ylim(), i obtain 1.0 whereas I observe it > is 2.0. > How can I obtain 2.0 for ymax ? > > Thanks. > > Kamel > Hi Kamel, I'm not seeing the same result: I actually get back (-1.94, 1.94) from `get_ylim`. When do you call `get_ylim`? Do you call it *after* calling `plot`? -Tony -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] ymax
On Wed, Jun 6, 2012 at 6:12 PM, Tony Yu wrote: > > > On Wed, Jun 6, 2012 at 3:32 PM, kamel maths wrote: > >> Hi, >> >> for this script: >> >> from pylab import * >> >> fig = figure() >> ax = fig.add_subplot(111) >> ax.axis('equal') >> >> x = linspace(-2, 3, 50) >> ax.plot(x, sin(x)) >> >> show() >> - >> If I try to get ymax with ax.get_ylim(), i obtain 1.0 whereas I observe >> it is 2.0. >> How can I obtain 2.0 for ymax ? >> >> Thanks. >> >> Kamel >> > > Hi Kamel, > > I'm not seeing the same result: I actually get back (-1.94, 1.94) from > `get_ylim`. When do you call `get_ylim`? Do you call it *after* calling > `plot`? > > -Tony > > Or, more likely, are you calling it *after* you close the figure? If so, then the axes has already been cleared and you are merely finding the limits for a newly created (but unshown) figure. Make sure you get the limits after the plotting, but before the show(). Ben Root -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users