Renato Alves | 1 Feb 01:40 2010
Picon

How to calculate relative positions between objects

Hi everyone

I've been going around matplotlib objects trying to find a way to
pre-calculate positions depending on input.

I'm trying to create a function that draws two barplots facing opposite
directions.

This is what I managed so far:

###

import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import gamma
from mpl_toolkits.axes_grid import make_axes_locatable

fig = plt.figure(1, (10, 10))
ax1 = fig.add_subplot(1, 1, 1)

ax1.set_xlim(1,0)

labels = ('0-9', '10-19', '20-29', '30-39', '40-49',
            '50-59', '60-69', '70-79', '80-89', '90-99')

pad = np.max([len(i) for i in labels]) * .15

divider = make_axes_locatable(ax1)
ax2 = divider.new_horizontal(size="100%", pad=pad, sharey=ax1)
fig.add_axes(ax2)
(Continue reading)

Matthieu Brucher | 1 Feb 10:21 2010
Picon

Re: Error with 0.99.2 when using Intel Compiler (Linux)

Hi again,

I've fixed the issue on my box. The issue lies in the definition of
the hash_map. For ICC for Linux, the GCC headers should be used.

Matthieu

2010/1/29 Matthieu Brucher <matthieu.brucher@...>:
> Hi,
>
> It seems that the compilation of base_format needs a C++ compiler, but
> distutils launches icc instead of icpc. This may work with gcc, but
> with Intel Compiler, I can't force icc to understand C++.
> I don't know what happened between 0.98.5 and 0.99.2, but I can't use
> Matplotlib anymore :|
>
> Matthieu
> --
> Information System Engineer, Ph.D.
> Blog: http://matt.eifelle.com
> LinkedIn: http://www.linkedin.com/in/matthieubrucher
>

--

-- 
Information System Engineer, Ph.D.
Blog: http://matt.eifelle.com
LinkedIn: http://www.linkedin.com/in/matthieubrucher

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
(Continue reading)

Torsten Andre | 1 Feb 10:34 2010
Picon

Draw data not in rectangular shape

Hi there,

I've got a a pylab 2D array which I plot using imshow() which just works
fine. But part of the data within the array is not to be considered nor
plotted. To keep it simple let's assume the data I need is shaped like a
triangle. It is no problem to extract the data from the matrix
converting the matrix to a list and dropping all unnecessary data.

My problem is that I don't know how to plot the data again. A possible
work around would be to set data elements which I don't need to some
value not in the data. But I since I need to compute histograms for the
data, for example, I have to drop the data anyways. Is there a way to
solve my problem?

Thanks for your help.
Cheers,
Torsten

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
Scott Sinclair | 1 Feb 14:06 2010
Picon

Re: Draw data not in rectangular shape

>On 1 February 2010 11:34, Torsten Andre <qa@...> wrote:
> I've got a a pylab 2D array which I plot using imshow() which just works
> fine. But part of the data within the array is not to be considered nor
> plotted.
>
> My problem is that I don't know how to plot the data again.

Hi Torsten,

Use NumPy masked arrays with imshow()
[http://docs.scipy.org/doc/numpy/reference/maskedarray.html]. You can
use the masked array just as you have been using your regular NumPy
array, they are designed for this purpose and Matplotlib will not plot
the masked portion of your data.

The pylab interface actually imports numpy so your pylab array is
really a NumPy ndarray object (try calling >>> print
type(your_pylab_array) to see this).

Cheers,
Scott

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
Tanja Gurzhiy | 1 Feb 13:51 2010
Picon

Possible workaround for memory leak using pylab.figure(), pylab.show() ?

Hi,

 

I have already submitted this issue as a possible problem to Tracker, however there is no response till now  http://sourceforge.net/tracker/?func=detail&aid=2940967&group_id=80706&atid=560720.  Probably, someone could help me with possible workaround for this problem.

I use the pylab.figure in the other application where a user should close the figure manually. After the figure is closed, I would expect the memory goes back to the level it was before. However, it is not the case, I have noticed a memory leak when using pylab.figure(), pylab.show().If I try to let show figure via pylan.ion(), then pylab.figure() and pylab.iof(), I also see the memory leak.
Below is simple example:

 

pylab.ion()

for i in range(10):

    pylab.figure()

    pylab.draw()

    val = cbook.report_memory(i)

    print i, val

pylab.ioff()

 

the same loop is used for show():

for i in range(10):

    pylab.figure()

    pylab.plot([1,3])

    val = cbook.report_memory(i)

    print i, val

pylab.show()


I use the python version 2.5.1, the matplotlib version 0.99.0, OS: SunOs5 (Solaris), backend: TkAgg.

 

Thanks in advance,

Tanja

 


------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Bruno Santos | 1 Feb 15:33 2010
Picon

Re: Possible workaround for memory leak using pylab.figure(), pylab.show() ?

Have you tried the pylab.close() this should force the flush of the memory. 

2010/2/1 Tanja Gurzhiy <tanja.gurzhiy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Hi,

 

I have already submitted this issue as a possible problem to Tracker, however there is no response till now  http://sourceforge.net/tracker/?func=detail&aid=2940967&group_id=80706&atid=560720.  Probably, someone could help me with possible workaround for this problem.

I use the pylab.figure in the other application where a user should close the figure manually. After the figure is closed, I would expect the memory goes back to the level it was before. However, it is not the case, I have noticed a memory leak when using pylab.figure(), pylab.show().If I try to let show figure via pylan.ion(), then pylab.figure() and pylab.iof(), I also see the memory leak.
Below is simple example:

 

pylab.ion()

for i in range(10):

    pylab.figure()

    pylab.draw()

    val = cbook.report_memory(i)

    print i, val

pylab.ioff()

 

the same loop is used for show():

for i in range(10):

    pylab.figure()

    pylab.plot([1,3])

    val = cbook.report_memory(i)

    print i, val

pylab.show()


I use the python version 2.5.1, the matplotlib version 0.99.0, OS: SunOs5 (Solaris), backend: TkAgg.

 

Thanks in advance,

Tanja

 



------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Yannick Copin | 1 Feb 16:15 2010
Picon

Size of ellipses in EllipseCollection

Hi,

I would like to plot lots of error ellipses on my plot. I thought I could use 
an EllipseCollection to do so, but I didn't manage to get the ellipse sizes, 
expressed in data units, right (see test script attached).

When using a plain list of Ellipse's, everything looks fine:

ells = [ P.matplotlib.patches.Ellipse(xy=xyi,
                                       width=wi, height=hi,
                                       angle=ai,
                                       edgecolor='b',
                                       facecolor='b',
                                       alpha=0.3)
          for xyi,wi,hi,ai in zip(xy,w,h,a)]
for ell in ells:
     ax.add_artist(ell)

But when using EllipseCollection (as explained in 
http://matplotlib.sourceforge.net/examples/pylab_examples/ellipse_collection.html), 

coll = P.matplotlib.collections.EllipseCollection(widths=w,
                                                   heights=h,
                                                   angles=a,
                                                   units='x',
                                                   offsets=xy,
                                                   transOffset=ax.transData,
                                                   edgecolor='r',
                                                   facecolor='r',
                                                   alpha=0.3)
ax.add_collection(coll)

the size of the ellipses (expressed in data units) appears incorrect, and 
depends furthermore of the aspect ratio of the figure (try pan/zoom or resize 
the interactive window).

I naively thought the two approaches should give the same result... Did I miss 
something in the way to use EllipseCollections?

Cheers,
-- 
    .~.   Yannick COPIN  (o:>*  Doctus cum libro
    /V\   Institut de physique nucleaire de Lyon (IN2P3 - France)
   // \\  Tel: (33/0) 472 431 968     AIM: YnCopin ICQ: 236931013
  /(   )\ http://snovae.in2p3.fr/ycopin/
   ^`~'^
Attachment (ellipseColl.py): text/x-python, 1504 bytes
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Tanja Gurzhiy | 1 Feb 16:47 2010
Picon

Re: Possible workaround for memory leak using pylab.figure(), pylab.show() ?

Hi
 
thanks for the answers, but I do not think it is applicable in this situation.
In the application I have an event that triggered (e.g., a button is pressed) the opening of the window by pylab.figure() and then the application shows (via figure pylab.show()) it to the user. So, the user defines when the figure will be closed.  So, if I use pylab.close(1) in the application, I cannot use pylab.show() afterwards in the code (because it will be nothing to show...) 
The only way I found to 'flush' the memory is via bind() based on the 'master' (e.g., master = Tkinter.Tk(), master.bind('<Destroy>', self.close_showed_figures()) but it is already late for the application because the memory leak is only of concern when 'master' does not destroyed.
 
Kind regards,
Tanja

On Mon, Feb 1, 2010 at 3:33 PM, Bruno Santos <bacmsantos <at> gmail.com> wrote:
Have you tried the pylab.close() this should force the flush of the memory. 

2010/2/1 Tanja Gurzhiy <tanja.gurzhiy <at> gmail.com>

Hi,

 

I have already submitted this issue as a possible problem to Tracker, however there is no response till now  http://sourceforge.net/tracker/?func=detail&aid=2940967&group_id=80706&atid=560720.  Probably, someone could help me with possible workaround for this problem.

I use the pylab.figure in the other application where a user should close the figure manually. After the figure is closed, I would expect the memory goes back to the level it was before. However, it is not the case, I have noticed a memory leak when using pylab.figure(), pylab.show().If I try to let show figure via pylan.ion(), then pylab.figure() and pylab.iof(), I also see the memory leak.
Below is simple example:

 

pylab.ion()

for i in range(10):

    pylab.figure()

    pylab.draw()

    val = cbook.report_memory(i)

    print i, val

pylab.ioff()

 

the same loop is used for show():

for i in range(10):

    pylab.figure()

    pylab.plot([1,3])

    val = cbook.report_memory(i)

    print i, val

pylab.show()


I use the python version 2.5.1, the matplotlib version 0.99.0, OS: SunOs5 (Solaris), backend: TkAgg.

 

Thanks in advance,

Tanja

 



------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/matplotlib-users



------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Torsten Andre | 1 Feb 17:51 2010
Picon

Re: Draw data not in rectangular shape

Scott Sinclair wrote:
>> On 1 February 2010 11:34, Torsten Andre <qa@...> wrote:
>> I've got a a pylab 2D array which I plot using imshow() which just works
>> fine. But part of the data within the array is not to be considered nor
>> plotted.
>>
>> My problem is that I don't know how to plot the data again.
> 
> Hi Torsten,
> 
> Use NumPy masked arrays with imshow()
> [http://docs.scipy.org/doc/numpy/reference/maskedarray.html]. You can
> use the masked array just as you have been using your regular NumPy
> array, they are designed for this purpose and Matplotlib will not plot
> the masked portion of your data.
> 
> The pylab interface actually imports numpy so your pylab array is
> really a NumPy ndarray object (try calling >>> print
> type(your_pylab_array) to see this).
> 
> Cheers,
> Scott
> 
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Hi Scott,

thank you very much. MA is exactly what I was looking for. Works
perfectly fine.

Cheers,
Torsten

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
Eric Firing | 1 Feb 19:15 2010

Re: Size of ellipses in EllipseCollection

Yannick Copin wrote:
> Hi,
> 
> I would like to plot lots of error ellipses on my plot. I thought I 
> could use an EllipseCollection to do so, but I didn't manage to get the 
> ellipse sizes, expressed in data units, right (see test script attached).
> 
> When using a plain list of Ellipse's, everything looks fine:
> 
> ells = [ P.matplotlib.patches.Ellipse(xy=xyi,
>                                       width=wi, height=hi,
>                                       angle=ai,
>                                       edgecolor='b',
>                                       facecolor='b',
>                                       alpha=0.3)
>          for xyi,wi,hi,ai in zip(xy,w,h,a)]
> for ell in ells:
>     ax.add_artist(ell)
> 
> But when using EllipseCollection (as explained in 
> http://matplotlib.sourceforge.net/examples/pylab_examples/ellipse_collection.html), 
> 
> 
> coll = P.matplotlib.collections.EllipseCollection(widths=w,
>                                                   heights=h,
>                                                   angles=a,
>                                                   units='x',
>                                                   offsets=xy,
>                                                   transOffset=ax.transData,
>                                                   edgecolor='r',
>                                                   facecolor='r',
>                                                   alpha=0.3)
> ax.add_collection(coll)
> 
> the size of the ellipses (expressed in data units) appears incorrect, 
> and depends furthermore of the aspect ratio of the figure (try pan/zoom 
> or resize the interactive window).

Maybe I am misunderstanding, but the EllipseCollection in the example is 
panning and zooming as I expect.  The shapes and orientations are 
staying the same while the scale expands and contracts with the x-axis.

The problem is that the option you are looking for does not exist yet. 
   I am not sure yet whether what you need is identical to an option I 
added to quiver (from which I partially derived EllipseCollection).  I 
suspect it is.

Do you want width to scale with x and height to scale with y?  And the 
angle to scale such that a 45-degree angle always corresponds to equal 
increments in x and in y, all in data units?

> 
> I naively thought the two approaches should give the same result... Did 
> I miss something in the way to use EllipseCollections?

EllipseCollection is derived more from quiver than from Ellipse.

Eric

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com

Gmane