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

2013-01-23 Thread Michael Droettboom

Does this pull request:

https://github.com/matplotlib/matplotlib/pull/1697

fix your issue?  I have no way of knowing without a test case...

Mike

On 01/22/2013 08:33 AM, Massimiliano Costacurta wrote:

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


--
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] append to or concatenate PathCollection objects?

2013-01-23 Thread Jonathan Slavin
Sterling,

I have version 1.2.0.  I read the legend guide.  Which thing should be
possible?  If you mean giving the points as a tuple, here's some simple
test code:

import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
ax = fig.add_subplot(1,1,1)
p1 = ax.scatter([0.1],[0.5],c='r',marker='s')
p2 = ax.scatter([0.3],[0.2],c='b',marker='o')
l = ax.legend((p1,p2),['points'],scatterpoints=2)
plt.show()

I get a legend with only red squares.  What I want is a legend line with
a red square and a blue circle.  I can get points with different colors
if I do:
p1 = ax.scatter([0.1,0.3],[0.5,0.2],c=('r','b'),marker='s')
l = ax.legend(['points'],scatterpoints=2)
(though as far as I can tell, you can't have a sequence of marker
types).

Jon

On Wed, 2013-01-23 at 09:57 -0800, Sterling Smith wrote:
> Jon,
> 
> What version of matplotlib do you have?  According to
> http://matplotlib.org/users/legend_guide.html
> what you say should be possible in 1.2.0.
> 
> -Sterling
> 
> On Jan 23, 2013, at 9:35AM, Jonathan Slavin wrote:
> 
> > Hi,
> > 
> > I'm wondering if there is some straightforward way to combine two
> > PathCollection objects to create a new PathCollection object.  My goal
> > is to include two points that use different axes (one twin'ed to the
> > other) into a single legend item (different point types, same label).
> > Each call to scatter creates a new PathCollection object.  If I could
> > just combine two (or more) PathCollection objects -- either extending
> > them or concatenating or whatever -- then I could give that to legend
> > and it would work correctly.  But it's not clear to me how I can do
> > that.  I tried providing the two objects as a tuple to legend, but it
> > doesn't work (only point characteristics of one of them is used).
> > 
> > Really, I think this should be easier -- both the combining of such
> > objects (which after all, are collections) and providing legend with
> > simple arguments to produce what you want.  As far as I can tell I can't
> > just tell leged directly the symbol type(s) and colors of point(s) per
> > each label.  Though in general the automatic method whereby you provide
> > the object to the legend is nice and easy, a more crude and direct way
> > would be a good option for special cases.
> > 
> > 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
> 

-- 
__
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] getting the dimensions of an axes

2013-01-23 Thread Paul Hobson
On Mon, Jan 21, 2013 at 4:28 AM, Kelson Zawack  wrote:

> a heat map and want to label each row.  I thus need the font
> size of the text to scale with the number of rows in the heat map.  Is
>

Assuming you start out with this:

import matplotlib.pyplot as plt
fig, ax1 = plt.subplots()

You can then do this:

figsize = fig.get_size_inches()
ax_pos = ax1.get_position().get_points()

The variable figsize is now a array of the figure's width and height. And
ax_pos is an array with the first row being the x-y location of the lower
left corner of the axes on the figure in figure fraction coordinates. The
second row is the width and height of the axes, again expressed as a
fraction of the total figure dimensions.

Hope that helps,
-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


[Matplotlib-users] append to or concatenate PathCollection objects?

2013-01-23 Thread Jonathan Slavin
Hi,

I'm wondering if there is some straightforward way to combine two
PathCollection objects to create a new PathCollection object.  My goal
is to include two points that use different axes (one twin'ed to the
other) into a single legend item (different point types, same label).
Each call to scatter creates a new PathCollection object.  If I could
just combine two (or more) PathCollection objects -- either extending
them or concatenating or whatever -- then I could give that to legend
and it would work correctly.  But it's not clear to me how I can do
that.  I tried providing the two objects as a tuple to legend, but it
doesn't work (only point characteristics of one of them is used).

Really, I think this should be easier -- both the combining of such
objects (which after all, are collections) and providing legend with
simple arguments to produce what you want.  As far as I can tell I can't
just tell leged directly the symbol type(s) and colors of point(s) per
each label.  Though in general the automatic method whereby you provide
the object to the legend is nice and easy, a more crude and direct way
would be a good option for special cases.

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


[Matplotlib-users] dash length for dashed contours

2013-01-23 Thread Andrew Dawson
Hi all,

[TL;DR: is it possible to control the length of the dashes in dashed
contours, if so how?]

I'd like to be able to control the length of dashes for dashed contours. My
motivation is that I'm making a contour plot that uses dashes for the
negative contours, and the plot needs to be a specific (small) size for the
particular journal, so the small size of the plot makes the dashes look
rather long and is a problem for some tight contours.

I have tried using some a dashes-style argument for the linestyles keyword
of contour but I can't get it to work (although I appreciate it is not
documented as something one can do). For example I tried:

import matplotlib.pyplot as plt
import numpy as np
x = y = np.linspace(-np.pi, np.pi, 100)
X, Y = np.meshgrid(x, y)
Z = np.sin(X) * np.cos(Y)
plt.contour(x, y, Z, linestyles=[(3, 3)])
plt.show()

This fails at the point where I show (or save, doesn't matter which
backend) the plot with a PyCXX error:

TypeError: PyCXX: Error creating object of type
N2Py7SeqBaseINS_6ObjectEEE from 3

I've fiddled with several other styles of argument and all fail in a
similar way.

What I'd like to know is: is it possible to control the dash length of
dashed contours at all? It seems like it should be as one can do this with
lines easy enough. I looked through the code, and a dashes-style argument
seems to get passed through the stack correctly, but fails when the
Collection is drawn. It would be a really nice feature if this could be
implemented in matplotlib.

Thanks,
Andrew
--
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