[Matplotlib-users] BUG: RuntimeError: dictionary changed size during iteration

2013-01-22 Thread Massimiliano Costacurta

Hello everyone,

in my program I'm encountering an error when calling the function 
axes.set_xticks (Matplotlib 1.2.0 on python 2.7-64 bit). It is really difficult 
for me to build a test case, because my program is really complex. Here is the 
error traceback:

File "C:\Python27\Lib\site-packages\matplotlib\axes.py", line 2596, in 
set_xticks
  return self.xaxis.set_ticks(ticks, minor=minor)
File "C:\Python27\Lib\site-packages\matplotlib\axis.py", line 1489, in set_ticks
  self.set_view_interval(min(ticks), max(ticks))
File "C:\Python27\Lib\site-packages\matplotlib\axis.py", line 1771, in 
set_view_interval
  max(vmin, vmax, Vmax))
File "C:\Python27\Lib\site-packages\matplotlib\transforms.py", line 932, in 
_set_intervalx
  self.invalidate()
File "C:\Python27\Lib\site-packages\matplotlib\transforms.py", line 131, in 
invalidate
  return self._invalidate_internal(value, invalidating_node=self)
File "C:\Python27\Lib\site-packages\matplotlib\transforms.py", line 155, in 
_invalidate_internal
  invalidating_node=self)
File "C:\Python27\Lib\site-packages\matplotlib\transforms.py", line 155, in 
_invalidate_internal
  invalidating_node=self)
File "C:\Python27\Lib\site-packages\matplotlib\transforms.py", line 155, in 
_invalidate_internal
  invalidating_node=self)
File "C:\Python27\Lib\site-packages\matplotlib\transforms.py", line 2141, in 
_invalidate_internal
  invalidating_node=invalidating_node)
File "C:\Python27\Lib\site-packages\matplotlib\transforms.py", line 155, in 
_invalidate_internal
  invalidating_node=self)
File "C:\Python27\Lib\site-packages\matplotlib\transforms.py", line 2141, in 
_invalidate_internal
  invalidating_node=invalidating_node)
File "C:\Python27\Lib\site-packages\matplotlib\transforms.py", line 153, in 
_invalidate_internal
  for parent in self._parents.itervalues():
File "C:\Python27\Lib\weakref.py", line 147, in itervalues
  for wr in self.data.itervalues(): 
RuntimeError: dictionary changed size during iteration

I googled and found that this is a well known bug due to the use of 
self.data.itervalues() in the for loop (i think the correct syntax should be 
for wr in iter(self.data.items()). So I would like to point out the bug (if it 
is) to the matplotlib guys, how can I do it?
In the meantime, how can I work around it without changing the source code?
Thanks in advance!
  --
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plotting 3d function

2013-01-22 Thread Benjamin Root
On Mon, Jan 21, 2013 at 8:06 PM, Pau  wrote:

> Hi,
>
> I am somehow new to matplotlib and I am trying to plot this function of x
> ,y ,z
>
> F(x,y,z)=
> 38244.74787*Pi*(x^2+y^2+z^2)^.125+1615.975261*Pi*z^2/(x^2+y^2+z^2)^.875-1292.780210*Pi*z^2/((x^2+y^2+z^2)^.875*(1+y^2/x^2))+1292.78*Pi*(x^2+y^2+z^2)^.125/(1+y^2/x^2)
>
> in a similar way as
>
> http://matplotlib.org/mpl_examples/mplot3d/contour3d_demo3.hires.png
>
> The code is
> http://matplotlib.org/mpl_examples/mplot3d/contour3d_demo3.py
>
> But I have no idea where to start...
>
> some help would be appreciated...
>
> thanks
>
>
The reason you are having difficulty coming up with a way to plot this is
because you have 3 input dimensions, and 1 output dimension that you wish
to plot.  If you were to plot this in 3D space, it would have to be done as
F(x,y,z) as a colored "mist" in the domain of (x,y,z).  While a "mist"
can't be done in mplot3d, you could plot out scatter points to emulate
this.  One could also use contourf3d(..., zdir='z', offset=...) to create
slices of the filled contours, similar to this example:

http://matplotlib.org/examples/mplot3d/contourf3d_demo2.html

Now, if the domain of (x,y,z) can be parameterized as a surface (i.e., a
sphere or a cylinder), then you are looking to do an image of F(x,y,z)
plotted on that surface, which is a little bit difficult, but also do-able
using the plot_surface() function.

Cheers!
Ben Root
--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Hiding labels in a legend?

2013-01-22 Thread David Erickson
Hello-
Prior to version 1.2 of MPL I was able to hide labels for certain
lines in the legend by setting the label=None when plotting a line,
however in 1.2 it is now showing the legend entry and visibly printing
"None".  Is there a workaround to hide the label?

Thanks,
David

--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] twiny and title

2013-01-22 Thread Jonathan Slavin
Hi,

I'm having some trouble with using twiny and a title on the plot.  The
title is writing over the axis label -- and even the tick labels.  I've
tried tight_layout() but it doesn't seem to help.  I could use fig.text
instead of title and place the title text where I want it (with a bit of
fiddling), but it'd be nice to have a more elegant solution.

Jon
-- 
__
Jonathan D. Slavin  Harvard-Smithsonian CfA
jsla...@cfa.harvard.edu 60 Garden Street, MS 83
phone: (617) 496-7981   Cambridge, MA 02138-1516
 cell: (781) 363-0035   USA
__


--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] twiny and title

2013-01-22 Thread Paul Hobson
On Tue, Jan 22, 2013 at 12:22 PM, Jonathan Slavin
wrote:

> Hi,
>
> I'm having some trouble with using twiny and a title on the plot.  The
> title is writing over the axis label -- and even the tick labels.  I've
> tried tight_layout() but it doesn't seem to help.  I could use fig.text
> instead of title and place the title text where I want it (with a bit of
> fiddling), but it'd be nice to have a more elegant solution.
>

Try this is a workaround:
fig, ax1 = plt.subplots()
ax2 = ax1.twiny()
ax1.plot(np.random.randn(50), 'gs')
ax2.plot(np.random.randn(50), 'bo')
ax1.set_title('Test Title')
ax2.xaxis.tick_bottom()
plt.show()

Does that help?
-paul
--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] twiny and title

2013-01-22 Thread Jonathan Slavin
Hi Paul,

This doesn't solve my problem since the whole point was to have two
separate x axes with different scales, etc.  One thing that I found that
does help is to use the suptitle() method of figure.  This at least puts
the title at the top of the figure and I can then fiddle with the top
offset for the subplot to get the title to not overlap the axis label.

Jon


On Tue, 2013-01-22 at 13:02 -0800, Paul Hobson wrote:
> 
> On Tue, Jan 22, 2013 at 12:22 PM, Jonathan Slavin
>  wrote:
> Hi,
> 
> I'm having some trouble with using twiny and a title on the
> plot.  The
> title is writing over the axis label -- and even the tick
> labels.  I've
> tried tight_layout() but it doesn't seem to help.  I could use
> fig.text
> instead of title and place the title text where I want it
> (with a bit of
> fiddling), but it'd be nice to have a more elegant solution.
> 
> 
> Try this is a workaround:
> fig, ax1 = plt.subplots()
> ax2 = ax1.twiny()
> ax1.plot(np.random.randn(50), 'gs')
> ax2.plot(np.random.randn(50), 'bo')
> ax1.set_title('Test Title')
> ax2.xaxis.tick_bottom()
> plt.show()
>  
> Does that help?
> -paul
> 
> 

-- 
__
Jonathan D. Slavin  Harvard-Smithsonian CfA
jsla...@cfa.harvard.edu 60 Garden Street, MS 83
phone: (617) 496-7981   Cambridge, MA 02138-1516
 cell: (781) 363-0035   USA
__


--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Hiding labels in a legend?

2013-01-22 Thread Benjamin Root
On Tue, Jan 22, 2013 at 1:57 PM, David Erickson wrote:

> Hello-
> Prior to version 1.2 of MPL I was able to hide labels for certain
> lines in the legend by setting the label=None when plotting a line,
> however in 1.2 it is now showing the legend entry and visibly printing
> "None".  Is there a workaround to hide the label?
>
> Thanks,
> David
>
>
I think you want "_nolegend_" for those labels.  The hiding of the labels
for None was an undocumented feature, I think, and has been "fixed".

http://matplotlib.org/api/axes_api.html#matplotlib.axes.Axes.legend

Cheers!
Ben Root
--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Hiding labels in a legend?

2013-01-22 Thread David Erickson
On Tue, Jan 22, 2013 at 1:20 PM, Benjamin Root  wrote:
>
>
> On Tue, Jan 22, 2013 at 1:57 PM, David Erickson 
> wrote:
>>
>> Hello-
>> Prior to version 1.2 of MPL I was able to hide labels for certain
>> lines in the legend by setting the label=None when plotting a line,
>> however in 1.2 it is now showing the legend entry and visibly printing
>> "None".  Is there a workaround to hide the label?
>>
>> Thanks,
>> David
>>
>
> I think you want "_nolegend_" for those labels.  The hiding of the labels
> for None was an undocumented feature, I think, and has been "fixed".
>
> http://matplotlib.org/api/axes_api.html#matplotlib.axes.Axes.legend
>

Perfect, thanks Ben!

-David

--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Hiding labels in a legend?

2013-01-22 Thread Drain, Theodore R (343P)
I have to say I disagree with this "fix".  None was a nice, very intuitive way 
to hide the label.  Many Python systems use None in that kind of role and I 
really doubt anyone is going to use None when they meant "None" so converting 
it to a string seems like a bad idea.

Ted


From: David Erickson [halcyon1...@gmail.com]
Sent: Tuesday, January 22, 2013 4:47 PM
To: Benjamin Root
Cc: matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] Hiding labels in a legend?

On Tue, Jan 22, 2013 at 1:20 PM, Benjamin Root  wrote:
>
>
> On Tue, Jan 22, 2013 at 1:57 PM, David Erickson 
> wrote:
>>
>> Hello-
>> Prior to version 1.2 of MPL I was able to hide labels for certain
>> lines in the legend by setting the label=None when plotting a line,
>> however in 1.2 it is now showing the legend entry and visibly printing
>> "None".  Is there a workaround to hide the label?
>>
>> Thanks,
>> David
>>
>
> I think you want "_nolegend_" for those labels.  The hiding of the labels
> for None was an undocumented feature, I think, and has been "fixed".
>
> http://matplotlib.org/api/axes_api.html#matplotlib.axes.Axes.legend
>

Perfect, thanks Ben!

-David

--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Hiding labels in a legend?

2013-01-22 Thread Benjamin Root
On Tue, Jan 22, 2013 at 9:10 PM, Drain, Theodore R (343P) <
theodore.r.dr...@jpl.nasa.gov> wrote:

> I have to say I disagree with this "fix".  None was a nice, very intuitive
> way to hide the label.  Many Python systems use None in that kind of role
> and I really doubt anyone is going to use None when they meant "None" so
> converting it to a string seems like a bad idea.
>
> Ted
>
>
IIRC, the problem is that in matplotlib, the python None has a special
meaning in most places ("do the default thing").  Legends, by default, will
create default labels.  For some time, we were capable of distinguishing
when someone submitted label=None and didn't state anything at all for
labels.  This often causes confusion down the draw stack, and we have been
working towards getting rid of such distinctions.

Of course, this is all from memory, which is notoriously bad.  If someone
else can bisect the commit that changed this, maybe that can refresh my
memory and maybe I could see a reason to re-instate this behavior.  Also,
if anyone can spot where it is stated in the documentation or examples that
None acts the same as "_nolegend_", then we can consider this a regression
and get it fixed.

Cheers!
Ben Root
--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Hiding labels in a legend?

2013-01-22 Thread Sterling Smith

On Jan 22, 2013, at 7:01PM, Benjamin Root wrote:

> 
> 
> On Tue, Jan 22, 2013 at 9:10 PM, Drain, Theodore R (343P) 
>  wrote:
> I have to say I disagree with this "fix".  None was a nice, very intuitive 
> way to hide the label.  Many Python systems use None in that kind of role and 
> I really doubt anyone is going to use None when they meant "None" so 
> converting it to a string seems like a bad idea.
> 
> Ted
> 
> 
> IIRC, the problem is that in matplotlib, the python None has a special 
> meaning in most places ("do the default thing").  Legends, by default, will 
> create default labels.  For some time, we were capable of distinguishing when 
> someone submitted label=None and didn't state anything at all for labels.  
> This often causes confusion down the draw stack, and we have been working 
> towards getting rid of such distinctions.
> 
> Of course, this is all from memory, which is notoriously bad.  If someone 
> else can bisect the commit that changed this, maybe that can refresh my 
> memory and maybe I could see a reason to re-instate this behavior.  Also, if 
> anyone can spot where it is stated in the documentation or examples that None 
> acts the same as "_nolegend_", then we can consider this a regression and get 
> it fixed.
> 
> Cheers!
> Ben Root

If None means do the default thing, then great.  I always interpreted the 
default for a plot command (line, patch, scatter, bar, etc.) to be no legend 
entry, unless explicitly given.  While not the specification as you have given 
it (default is default labels), this is my working specification (I have not 
yet migrated to 1.2.0).

Cheers,
Sterling

PS Notwithstanding this possible point of difference of opinion, I think the 
matplotlib team is awesome, and puts out a great product.  So I am willing to 
concede the point if no reversion is made.



--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users