Re: [Matplotlib-users] Fwd: zoomed in detail box

2012-09-12 Thread darkside
Thank you for your help.

A simple example that doesn't work for me is:

import pylab as p
import numpy as np
from mpl_toolkits.axes_grid.inset_locator import zoomed_inset_axes
from mpl_toolkits.axes_grid.inset_locator import mark_inset
from mpl_toolkits.axes_grid.anchored_artists import AnchoredSizeBar
from matplotlib.ticker import MaxNLocator

fig = p.figure(figsize=(12,8))
ax = p.subplot(111)

z = p.arange(0,1.415,0.01)
d = z**2+np.random.random(len(z))

ax.plot(z,d,'ro',label='text')

p.xlabel('z',fontsize=18)
p.ylabel('Luminosity distance',fontsize=18)
p.grid(True)

axins = zoomed_inset_axes(ax,
3,bbox_to_anchor=(0.5,0.5),bbox_transform=ax.figure.transFigure, loc=2)


axins.plot(z,d,'r.')

ax.legend(loc=2,bbox_to_anchor=(1,1))

x,y = (0.86,1.3)
x2,y2 = (1,1.7)
axins.set_xlim(x,x2)
axins.set_ylim(y,y2)
axins.tick_params(axis='both',labelsize=12)
axins.xaxis.set_major_locator(MaxNLocator(2))
axins.yaxis.set_major_locator(MaxNLocator(3))

mark_inset(ax,axins,loc1=1,loc2=3, fc="none", ec="0.5")

p.draw()
p.show()
---
The "bbox_to_anchor" label is supposed to move the zoomed axis, but it does
nothing, no matter what two numbers I place there.
I guess that I miss something, but I can't figure out what. I really
appreciate your help.

Best regards,
Illa


2012/9/5 Jae-Joon Lee 

> On Mon, Aug 20, 2012 at 10:50 PM, darkside 
> wrote:
> > I am using zoomed_inset_axes, but the default position overlaps the
> yticks
> > and the parent axe ticks, so I am trying:
> > axins = zoomed_inset_axes(ax,
> > 3,bbox_to_anchor(0.5,1),bbox_transform=ax.figure.transFigure, loc=2)
>
> This is supposed to work, and my quick test did work. Can you post a
> complete but simple exampl?
>
> Regards,
>
> -JJ
>
--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Fwd: zoomed in detail box

2012-09-12 Thread Jae-Joon Lee
Your code works as expected in my side.
So, changing (0.5, 0.5) to something like  (0.6, 0.5) has no effect in
your side?
Hmm, what is you matplotlib version? Maybe this is a bug in old
version of matplotlib.

Regards,

-JJ


On Wed, Sep 12, 2012 at 6:16 PM, darkside  wrote:
> Thank you for your help.
>
> A simple example that doesn't work for me is:
> 
> import pylab as p
> import numpy as np
> from mpl_toolkits.axes_grid.inset_locator import zoomed_inset_axes
> from mpl_toolkits.axes_grid.inset_locator import mark_inset
> from mpl_toolkits.axes_grid.anchored_artists import AnchoredSizeBar
> from matplotlib.ticker import MaxNLocator
>
> fig = p.figure(figsize=(12,8))
> ax = p.subplot(111)
>
> z = p.arange(0,1.415,0.01)
> d = z**2+np.random.random(len(z))
>
> ax.plot(z,d,'ro',label='text')
>
> p.xlabel('z',fontsize=18)
> p.ylabel('Luminosity distance',fontsize=18)
> p.grid(True)
>
> axins = zoomed_inset_axes(ax,
> 3,bbox_to_anchor=(0.5,0.5),bbox_transform=ax.figure.transFigure, loc=2)
>
>
> axins.plot(z,d,'r.')
>
> ax.legend(loc=2,bbox_to_anchor=(1,1))
>
> x,y = (0.86,1.3)
> x2,y2 = (1,1.7)
> axins.set_xlim(x,x2)
> axins.set_ylim(y,y2)
> axins.tick_params(axis='both',labelsize=12)
> axins.xaxis.set_major_locator(MaxNLocator(2))
> axins.yaxis.set_major_locator(MaxNLocator(3))
>
> mark_inset(ax,axins,loc1=1,loc2=3, fc="none", ec="0.5")
>
> p.draw()
> p.show()
> ---
> The "bbox_to_anchor" label is supposed to move the zoomed axis, but it does
> nothing, no matter what two numbers I place there.
> I guess that I miss something, but I can't figure out what. I really
> appreciate your help.
>
> Best regards,
> Illa
>
>
>
> 2012/9/5 Jae-Joon Lee 
>>
>> On Mon, Aug 20, 2012 at 10:50 PM, darkside 
>> wrote:
>> > I am using zoomed_inset_axes, but the default position overlaps the
>> > yticks
>> > and the parent axe ticks, so I am trying:
>> > axins = zoomed_inset_axes(ax,
>> > 3,bbox_to_anchor(0.5,1),bbox_transform=ax.figure.transFigure, loc=2)
>>
>> This is supposed to work, and my quick test did work. Can you post a
>> complete but simple exampl?
>>
>> Regards,
>>
>> -JJ
>
>

--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] zoomed in detail box

2012-09-12 Thread Dale Chayes
[replying only to the list -Dale]

On Sep 12, 2012, at 07:02 , Jae-Joon Lee wrote:

> Your code works as expected in my side.

I wasn't quite sure what to expect, but based on Jae-Joon's note:

> So, changing (0.5, 0.5) to something like  (0.6, 0.5) has no effect in
> your side?

It seems to work on my installation. I actually changed to (0.3,0.5) which made 
a nice view.
 
> Hmm, what is you matplotlib version?

OS X 10.7.4 using python and tools from fink: 
i   python27 1:2.7.3-1
i   python27-shlibs  1:2.7.3-1
i   matplotlib-basemap-py27  1.0.2-1
i   matplotlib-py27  1.1.1-1
i   numpy-py27   1.6.1-1

Thanks to the folks who make this work,
-Dale


> Maybe this is a bug in old version of matplotlib.
> 
> Regards,
> 
> -JJ
> 
> 
> On Wed, Sep 12, 2012 at 6:16 PM, darkside  wrote:
>> Thank you for your help.
>> 
>> A simple example that doesn't work for me is:
>> 
>> import pylab as p
>> import numpy as np
>> from mpl_toolkits.axes_grid.inset_locator import zoomed_inset_axes
>> from mpl_toolkits.axes_grid.inset_locator import mark_inset
>> from mpl_toolkits.axes_grid.anchored_artists import AnchoredSizeBar
>> from matplotlib.ticker import MaxNLocator
>> 
>> fig = p.figure(figsize=(12,8))
>> ax = p.subplot(111)
>> 
>> z = p.arange(0,1.415,0.01)
>> d = z**2+np.random.random(len(z))
>> 
>> ax.plot(z,d,'ro',label='text')
>> 
>> p.xlabel('z',fontsize=18)
>> p.ylabel('Luminosity distance',fontsize=18)
>> p.grid(True)
>> 
>> axins = zoomed_inset_axes(ax,
>> 3,bbox_to_anchor=(0.5,0.5),bbox_transform=ax.figure.transFigure, loc=2)
>> 
>> 
>> axins.plot(z,d,'r.')
>> 
>> ax.legend(loc=2,bbox_to_anchor=(1,1))
>> 
>> x,y = (0.86,1.3)
>> x2,y2 = (1,1.7)
>> axins.set_xlim(x,x2)
>> axins.set_ylim(y,y2)
>> axins.tick_params(axis='both',labelsize=12)
>> axins.xaxis.set_major_locator(MaxNLocator(2))
>> axins.yaxis.set_major_locator(MaxNLocator(3))
>> 
>> mark_inset(ax,axins,loc1=1,loc2=3, fc="none", ec="0.5")
>> 
>> p.draw()
>> p.show()
>> ---
>> The "bbox_to_anchor" label is supposed to move the zoomed axis, but it does
>> nothing, no matter what two numbers I place there.
>> I guess that I miss something, but I can't figure out what. I really
>> appreciate your help.
>> 
>> Best regards,
>> Illa
>> 
>> 
>> 
>> 2012/9/5 Jae-Joon Lee 
>>> 
>>> On Mon, Aug 20, 2012 at 10:50 PM, darkside 
>>> wrote:
 I am using zoomed_inset_axes, but the default position overlaps the
 yticks
 and the parent axe ticks, so I am trying:
 axins = zoomed_inset_axes(ax,
 3,bbox_to_anchor(0.5,1),bbox_transform=ax.figure.transFigure, loc=2)
>>> 
>>> This is supposed to work, and my quick test did work. Can you post a
>>> complete but simple exampl?
>>> 
>>> Regards,
>>> 
>>> -JJ
>> 
>> 
> 
> --
> 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
> [email protected]
> 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] a memory leak in matplotlib plot embedded inwxpython

2012-09-12 Thread Barraclough, Dominic (ext. 414)
 

Happiness - Upgrading numpy to v 1.6.2 - I had been using 1.6.0b - seems
to have fixed things - my app's memory usage is now flat.

 

Dominic

 



From: Barraclough, Dominic (ext. 414) [mailto:[email protected]] 
Sent: Tuesday, September 11, 2012 4:28 PM
To: [email protected]
Subject: [Matplotlib-users] a memory leak in matplotlib plot embedded
inwxpython

 

 

I'm using matplotlib plots embedded in a wxpython application to display
a stream of data. The application works effectively but I have noticed
that memory usage rises substantially over time (if left long enough the
process can go from 50MB to near 1GB of RAM). After some
experimentation, I have tracked the problem down to the canvas.draw()
call needed to refresh my matplotlib plos. Thinking that the problem may
be due to how I coded up my plots I looked to see if the problem was
present in the examples given at

 

http://matplotlib.sourceforge.net/examples/user_interfaces

 

and found that the problem seem to be present in some the examples
posted there if I added a timer to cause the canvas draw to be
repeatedly performed. 

 

 

The example below is based on  

 

http://matplotlib.sourceforge.net/examples/user_interfaces/embedding_in_
wx2.html

 

and has been instrumented to report memory usage when running in
Windows. My tests indicate that working set memory rises by 11 to 12
Kbytes at each plot. 

 

Some what to my surprise, I found the same issue when I ran an even
simpler version on a linux mint virtual box running on my win7 system.
(I have not explored this much so somebody else might want to test
things on a non virtual linux box)  I assume this implies that python is
probably keeping something alive that was expected to be automatically
cleaned up at each draw. I have made some effort to localize the problem
further but right now I don't have the necessary  time to get heavily
into the inner workings of matplotlib or wxpython 

 

Has any body else seen this problem before, and if so, has any body a
work around that allows rapid replotting - I would guess that I could
periodically flush the figure and re build my plots but this would cause
periodic glitches in plotting? 

 

 

Dominic

 

 

System details

 

Win7 ultimate service pack1

Python 2.6.6 (but I've seen the problem with python2.5 and 2.7)

Matplotlib 1.1.1 (but also in earlier versions)

Wxpython 2.9.4.0 msw (classic) (put also on 2.8.12.0 unicode)

 

 

Example 


---

import wxversion

wxversion.ensureMinimal('2.8')

 

from numpy import arange, sin, pi

 

import matplotlib

 

# uncomment the following to use wx rather than wxagg

#matplotlib.use('WX')

#from matplotlib.backends.backend_wx import FigureCanvasWx as
FigureCanvas

 

# comment out the following to use wx rather than wxagg

matplotlib.use('WXAgg')

from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as
FigureCanvas

 

from matplotlib.backends.backend_wx import NavigationToolbar2Wx

 

from matplotlib.figure import Figure

import win32process

import wx

 

class CanvasFrame(wx.Frame):

 

def __init__(self):

wx.Frame.__init__(self,None,-1,

 'CanvasFrame',size=(550,350))

 

#self.SetBackgroundColour(wx.NamedColor("WHITE")) # 2.9 does not
like

 

self.figure = Figure()

self.axes = self.figure.add_subplot(111)

t = arange(0.0,3.0,0.01)

s = sin(2*pi*t)

 

self.axes.plot(t,s)

self.canvas = FigureCanvas(self, -1, self.figure)

 

self.sizer = wx.BoxSizer(wx.VERTICAL)

self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)

self.SetSizer(self.sizer)

self.Fit()

 

self.add_toolbar()  # comment this out for no toolbar

self.timer = wx.Timer(self, -1)



self.Bind(wx.EVT_TIMER, self.OnUpdate)

self.delay = 200

self.timer.Start(self.delay, oneShot = False)

self.proc_id = win32process.GetCurrentProcess()

adict = win32process.GetProcessMemoryInfo(self.proc_id)

self.memory_old = adict["WorkingSetSize"]

self.i = 0



def add_toolbar(self):

self.toolbar = NavigationToolbar2Wx(self.canvas)

self.toolbar.Realize()

if wx.Platform == '__WXMAC__':

# Mac platform (OSX 10.3, MacPython) does not seem to cope
with

# having a toolbar in a sizer. This work-around gets the
buttons

# back, but at the expense of having the toolbar at the top

self.SetToolBar(self.toolbar)

else:

# On Windows platform, default window size is incorrect, so
set

# toolbar width to figure width.

tw, th = self.toolbar.GetSizeTuple()

fw, fh = self.canvas.GetSizeTuple()

# By adding t

Re: [Matplotlib-users] legend(loc='best') not so great

2012-09-12 Thread Aronne Merrelli
On Tue, Sep 11, 2012 at 10:49 AM, Damon McDougall
 wrote:
> On Tue, Sep 11, 2012 at 3:34 PM, Neal Becker  wrote:
>> OK, I've attached my sanitized example
>>
>
> ImportError: No module named pandas.
>
> Can you provide an example that doesn't depend on pandas?
>

I was playing with this example to remove the pandas stuff, and It
looks a lot like the check for the best legend location is just not
accounting correctly for the multiple legend entries in this case.
Here is an even more minimal example, that I think reproduces the same
problem as Neal's original example.

colors = ['b','g','r']
for n in range(3):
plt.scatter([n,],[n,],color=colors[n])
plt.legend(['foo','foo','foo'],loc='best')


Note that if you just put one legend name in there, the location is
perfectly fine, it is just as it extends downward for the second and
third names, that it covers over the point.

FYI: Im using v1.1.0 mpl, in EPD 7.2.

HTH,
Aronne

--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] legend(loc='best') not so great

2012-09-12 Thread Damon McDougall
On Wed, Sep 12, 2012 at 5:57 PM, Aronne Merrelli
 wrote:
> On Tue, Sep 11, 2012 at 10:49 AM, Damon McDougall
>  wrote:
>> On Tue, Sep 11, 2012 at 3:34 PM, Neal Becker  wrote:
>>> OK, I've attached my sanitized example
>>>
>>
>> ImportError: No module named pandas.
>>
>> Can you provide an example that doesn't depend on pandas?
>>
>
> I was playing with this example to remove the pandas stuff, and It
> looks a lot like the check for the best legend location is just not
> accounting correctly for the multiple legend entries in this case.
> Here is an even more minimal example, that I think reproduces the same
> problem as Neal's original example.
>
> colors = ['b','g','r']
> for n in range(3):
> plt.scatter([n,],[n,],color=colors[n])
> plt.legend(['foo','foo','foo'],loc='best')
>
>
> Note that if you just put one legend name in there, the location is
> perfectly fine, it is just as it extends downward for the second and
> third names, that it covers over the point.
>
> FYI: Im using v1.1.0 mpl, in EPD 7.2.
>
> HTH,
> Aronne
>

Aronne, thanks for taking the time to produce a nice example. I can
now recreate the problem. I'm not sure how invasive it will be to fix
this, so it possibly won't make it in for version 1.2, but possibly a
bugfix release after the fact.

For anyone who's interested, here's the github issue:
https://github.com/matplotlib/matplotlib/issues/1235

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

--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Drag, add, remove points from a plot with the mouse

2012-09-12 Thread Filipe Pires Alvarenga Fernandes
Hi all,

I am trying to create a class to edit the points of a plot based on
the poly_editor.py example.  However, I have very little experience
with even handling and I need some help.

Here is what I did so far, the "toggle" on/off works fine.  Also I
believe that actions "press", "release", "insert", "delete" are OK.
However, I am stuck at the drawing part of the problem.

if anyone have an example of that to share or it you want to check
what I made so far:

http://dl.dropbox.com/u/4411725/point_editor.py

Thanks, Filipe.

--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Drag, add, remove points from a plot with the mouse

2012-09-12 Thread Filipe Pires Alvarenga Fernandes
After some modifications and manual reading I got "insert" point and
"delete" point working, but I still cannot make the "drag" point
work...

-Filipe


On Wed, Sep 12, 2012 at 4:04 PM, Filipe Pires Alvarenga Fernandes
 wrote:
> Hi all,
>
> I am trying to create a class to edit the points of a plot based on
> the poly_editor.py example.  However, I have very little experience
> with even handling and I need some help.
>
> Here is what I did so far, the "toggle" on/off works fine.  Also I
> believe that actions "press", "release", "insert", "delete" are OK.
> However, I am stuck at the drawing part of the problem.
>
> if anyone have an example of that to share or it you want to check
> what I made so far:
>
> http://dl.dropbox.com/u/4411725/point_editor.py
>
> Thanks, Filipe.

--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Drag, add, remove points from a plot with the mouse

2012-09-12 Thread Filipe Pires Alvarenga Fernandes
OK, a little bit more of manual reading I got the "drag point"
working.  Now, even though it works, I would like the opinion of
someone with more experience on event handling to improve that.

Thanks, Filipe

On Wed, Sep 12, 2012 at 6:14 PM, Filipe Pires Alvarenga Fernandes
 wrote:
> After some modifications and manual reading I got "insert" point and
> "delete" point working, but I still cannot make the "drag" point
> work...
>
> -Filipe
>
>
> On Wed, Sep 12, 2012 at 4:04 PM, Filipe Pires Alvarenga Fernandes
>  wrote:
>> Hi all,
>>
>> I am trying to create a class to edit the points of a plot based on
>> the poly_editor.py example.  However, I have very little experience
>> with even handling and I need some help.
>>
>> Here is what I did so far, the "toggle" on/off works fine.  Also I
>> believe that actions "press", "release", "insert", "delete" are OK.
>> However, I am stuck at the drawing part of the problem.
>>
>> if anyone have an example of that to share or it you want to check
>> what I made so far:
>>
>> http://dl.dropbox.com/u/4411725/point_editor.py
>>
>> Thanks, Filipe.

--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] linestyles in matplotlib.pyplot.plot

2012-09-12 Thread Goutam Paul
It seems that there are only five line-styles:

"-" (solid) – default
"--" (dashed)
"-." (dash dot)
":" (dotted)
"None" or " " or "" (nothing)

What if I want to have more linestyles? Say, ++, **, xx, ~~, etc. Is it
possible to have user-defined linestyles? How?
--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] linestyles in matplotlib.pyplot.plot

2012-09-12 Thread Damon McDougall
On Wed, Sep 12, 2012 at 11:31 PM, Goutam Paul  wrote:
> It seems that there are only five line-styles:
>
> "-" (solid) – default
> "--" (dashed)
> "-." (dash dot)
> ":" (dotted)
> "None" or " " or "" (nothing)
>
> What if I want to have more linestyles? Say, ++, **, xx, ~~, etc. Is it
> possible to have user-defined linestyles? How?
>

User-defined line styles is difficult. There is an open github issue
on this topic: https://github.com/matplotlib/matplotlib/issues/346

Though, porting some of the existing markers over as linestyles would
be a nice addition, I think.

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

--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users