[matplotlib-devel] fix to markers.py

2011-12-18 Thread Alexander Heger
In [1]: matplotlib.__version__
Out[1]: '1.2.x'


~/matplotlib/lib/matplotlib>diff  markers.py_broken markers.py
190c190
< path = Path(verts)
---
 > path = Path(self._marker)

PS - I tried to log into
https://github.com/matplotlib/matplotlib/issues
using my mailing list password to create a bug report, but it would not 
accept it, so you get it this way.

DOCUMENTATION NOTES

1) in the table for marker vertices it states

http://matplotlib.sourceforge.net/api/artist_api.html#matplotlib.lines.Line2D.set_marker

verts   a list of (x, y) pairs in range (0, 1)

it really should be just normalized or abs(1), (0,0) being center, and 
hence the (x,y) values should be in the range (-1,+1).  Would be good to 
add an example

x=np.linspace(0,1,10)**2
plot(x,c='r',marker=((-1.,-1),(1.,-1),(1.,1.),(-1,1.),(-1,-1)),ms=10)

2) the source also support to just provide a path as a marker, which (a) 
is cool, and (b) seemed natural as internal many things are done a 
paths, and even complies paths are generated from the $...$ syntax math. 
  In any case, this should be added to the documentation for allowed markers

patha matplotlib.path.Path object

import matplotlib.path as path
x = np.linspace(0,1,10)**2
p = path.Path(((-1.,-1),(1.,-1),(1.,1.),(-1,1.),(-1,-1)))
plot(x,c='r',marker=p,ms=10)

or a cool example that you may want tot add to the library...

import matplotlib.path as path

# define codes
P = path.Path
Pm = P.MOVETO
Pl = P.LINETO
Pc = P.CLOSEPOLY
c = [Pm] + [Pl]*3 + [Pc]
cx=c*2

# define basic path
r=np.array(((-1.,-1),(1.,-1),(1.,1.),(-1,1.),(-1,-1)))
# we add second closed path of half size but reverse parity
rh=0.5*r[::-1]
rx = np.vstack((r,rh))
p = path.Path(rx,codes=cx)

x = np.linspace(0,1,10)**2
plot(x,c='r',marker=p,ms=10)

PS - I guess I need to figure out how to do such updates w/o requesting 
action from the lest eventually.

Just to emphasize (2a): COOL!!!

Wishlist:
Can we add a "transform" parameter to overwrite self._transform?
I suppose this would have to go many places.

"set_marker_transform"

Maybe add to MarkerStyle

from transforms import Transform
def self.set_transform(self, transform = IdentityTransform()):
 assert isinstance(x, Transform)
 self._transfrom = transfrom()


Maybe less fancy, and better for starters, to add an angle

"set_marker_rotation(angle)"

using

Affine2D().rotate_deg(angle)


-Alexander

--
Learn Windows Azure Live!  Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for 
developers. It will provide a great way to learn Windows Azure and what it 
provides. You can attend the event by watching it streamed LIVE online.  
Learn more at http://p.sf.net/sfu/ms-windowsazure
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


[matplotlib-devel] another change request to markers.py

2011-12-18 Thread Alexander Heger
Sorry for the multiple mailings.

in makers.py I request to change

  def _set_custom_marker(self, path):
  verts = path.vertices
  rescale = max(np.max(np.abs(verts[:,0])),
np.max(np.abs(verts[:,1])))
  self._transform = Affine2D().scale(1.0 / rescale)
  self._path = path

to

  def _set_custom_marker(self, path):
  verts = path.vertices
  rescale = np.max(np.sqrt(np.square(verts[:,0]) +
np.square(verts[:,1])))
  self._transform = Affine2D().scale(1.0 / rescale)
  self._path = path

such that the symbol *radius* is normalized to 1.0

This way my previous example give better results if the symbol is rotated:

import matplotlib.path as path
from matplotlib.transforms import Affine2D

# define codes
P = path.Path
Pm = P.MOVETO
Pl = P.LINETO
Pc = P.CLOSEPOLY
c = [Pm] + [Pl]*3 + [Pc]
cx=c*2

# define basic path
r=np.array(((-1.,-1),(1.,-1),(1.,1.),(-1,1.),(-1,-1)))
# we add second closed path of half size but reverse parity
rh=0.5*r[::-1]
rx = np.vstack((r,rh))
p = path.Path(rx,codes=cx)

x = np.linspace(0,1,10)**2
plot(x,c='r',marker=p,ms=10)

pr = p.transformed(Affine2D().rotate_deg(45.))
plot(x,c='r',marker=pr,ms=10)

show()

I think this is how it is "meant" to be, but maybe you have to add a
parameter to allow people recover the current behavior in that case.

-Alexander


I just like round cows better than square cows.

--
Learn Windows Azure Live!  Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for 
developers. It will provide a great way to learn Windows Azure and what it 
provides. You can attend the event by watching it streamed LIVE online.  
Learn more at http://p.sf.net/sfu/ms-windowsazure
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel