Re: [matplotlib-devel] Beginnings of usetex support for pdf backend (by reading dvi files)
On Monday 09 April 2007 07:40:35 am Jouni K. Seppänen wrote: > I just committed the beginnings of draw_tex for the pdf backend, which > uses the dvi reader in the new file dviread.py. This is all in a very > rudimentary stage, but I'm committing now since I won't likely have > much time to work on this in the near future. In the meantime, if > anyone's interested in developing it further, take a look at > backend_pdf.py for caveats and how to enable it. > > The following script produces the attached output; note that the > \alpha is broken (must be some encoding issues) but the underscore > command \_ works, unlike in plain mathtext. > > #!/usr/bin/env python > import matplotlib > matplotlib.use('PDF') > from pylab import * > rc('text', usetex=True) > rc('font', serif='Computer Modern Roman', size=10) > subplot(111) > setp(gca(), xticks=[], yticks=[]) > text(0.5, 0.5, r'$f(x)=\alpha\_1$', fontsize=10) > savefig('foobar.pdf') This looks like a great start, Jouni. At least three times in the past, I have tried to get started on writing a dvi parser for exactly this purpose, and I never could make any real progress on it in the amount of time I had available. Plus, I was in over my head and had to relearn a lot each time I started over. I'm really impressed with what you have done. Nice work! Darren - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
[matplotlib-devel] Two small patches
Hi All, I've attached a patch which addresses two small issues. The first is a bug in patches.py. When doing 3d scatter plots xs, ys = zip(*self.xy) (line 480) crashes, as the right hand side expands to 3 values. The other is a speedup, normalising an entire array at once, rather than element by element, speeding up the attached script by a factor of 6x (and upgrading my actual application from 'too slow' to 'quite reasonable' :-) Cheers, Tim Index: lib/matplotlib/art3d.py === --- lib/matplotlib/art3d.py (revision 3193) +++ lib/matplotlib/art3d.py (working copy) @@ -369,7 +369,7 @@ """Modify the alphas of the color list according to depth""" colors = get_colors(colors,len(zs)) norm = Normalize(min(zs),max(zs)) -sats = nx.array([1-norm(z)*0.7 for z in zs]) +sats = 1 - norm(zs)*0.7 colors = [(c[0],c[1],c[2],c[3]*s) for c,s in zip(colors,sats)] return colors Index: lib/matplotlib/patches.py === --- lib/matplotlib/patches.py (revision 3193) +++ lib/matplotlib/patches.py (working copy) @@ -480,7 +480,7 @@ def get_verts(self): -xs, ys = zip(*self.xy) +xs, ys = zip(*self.xy)[:2] xs = self.convert_xunits(xs) ys = self.convert_yunits(ys) return zip(xs, ys) import random import pylab as p import matplotlib.axes3d as p3 def main(): fig = p.figure() ax = p3.Axes3D(fig) pts = 7500 X = range(pts) Y = range(pts) Z = range(pts) ax.scatter3D(X, Y, Z) p.savefig("tmp.png") if __name__ == '__main__': import hotshot, hotshot.stats prof = hotshot.Profile("stones.prof") benchtime = prof.runcall(main) prof.close() stats = hotshot.stats.load("stones.prof") stats.strip_dirs() stats.sort_stats('cumulative', 'calls') stats.print_stats(20) - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] Two small patches
On 4/9/07, Tim Leslie <[EMAIL PROTECTED]> wrote: > > The other is a speedup, normalising an entire array at once, rather > than element by element, speeding up the attached script by a factor > of 6x (and upgrading my actual application from 'too slow' to 'quite > reasonable' :-) Thanks Tim, I just committed this. I see that my sinister plan of releasing the 3d stuff w/o support in hopes of reeling in contributers is starting to work - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] Two small patches
On 4/10/07, John Hunter <[EMAIL PROTECTED]> wrote: > On 4/9/07, Tim Leslie <[EMAIL PROTECTED]> wrote: > > > > > The other is a speedup, normalising an entire array at once, rather > > than element by element, speeding up the attached script by a factor > > of 6x (and upgrading my actual application from 'too slow' to 'quite > > reasonable' :-) > > Thanks Tim, I just committed this. I see that my sinister plan of > releasing the 3d stuff w/o support in hopes of reeling in contributers > is starting to work Well I've got a bit of work to do which involves 3D stuff in the coming week or so, so if I run up against anything else I'll keep the patches coming. Thanks for the quick commit. Cheers, Tim > > > - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
[matplotlib-devel] What is the OS-C egg built against?
Hi all, I'm having trouble getting an MPL 0.90.0 working with wxPython 2.8 on OS-X. Does anyone know what the egg on the sourceforge site is built with? Is that documented somewhere? As I understand it, Ken made some changes for wxPython 2.8 in svn, but I don't see any mention of them in the 0.90.0 CHANGELOG, so it looks like they haven't made it into the distribution yet. darn. oh well, off to set things up to compile. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] Two small patches
On 4/10/07, John Hunter <[EMAIL PROTECTED]> wrote: On 4/9/07, Tim Leslie <[EMAIL PROTECTED]> wrote: > > The other is a speedup, normalising an entire array at once, rather > than element by element, speeding up the attached script by a factor > of 6x (and upgrading my actual application from 'too slow' to 'quite > reasonable' :-) Thanks Tim, I just committed this. I see that my sinister plan of releasing the 3d stuff w/o support in hopes of reeling in contributers is starting to work Here's another patch. This one cleans up the line2d_seg_dist function and also speeds it up by a factor of ~2. Cheers, Tim Index: proj3d.py === --- proj3d.py (revision 3198) +++ proj3d.py (working copy) @@ -51,52 +51,28 @@ x0,y0 = p return abs((a*x0 + b*y0 + c)/nx.sqrt(a**2+b**2)) -def dist2d(p0,p1): -"""distance between two points""" -try: -p = p0-p1 -return nx.sqrt(sum(p**2)) -except ValueError: -print p0,p1 -raise -def line2d_seg_dist(p0,p1, p): -"""distance(s) from line defined by p0 - p1 to point(s) p +def line2d_seg_dist(p1,p2, p0): +"""distance(s) from line defined by p1 - p2 to point(s) p0 -p[0] = x(s) -p[1] = y(s) +p0[0] = x(s) +p0[1] = y(s) -intersection point p = p0 + u*(p1-p0) +intersection point p = p1 + u*(p2-p1) and intersection point lies within segement if u is between 0 and 1 """ - -p,p0,p1 = map(nx.asarray,(p[:2],p0[:2],p1[:2])) -x,y = p -x0,y0 = p0 -x1,y1 = p1 -# -u = ((x-x0)*(x1-x0)+(y-y0)*(y1-y0))/(dist2d(p0,p1)*dist2d(p0,p1)) -# -def dist(p,p0,p1,u): -if u > 0 and u < 1: -pi = p0 + u*(p1-p0) -return dist2d(p,pi) -else: -return nx.minimum(dist2d(p,p0),dist2d(p,p1)) - -if not iterable(u): -return dist(p,p0,p1,u) -else: -# for each point calculate dist -pt = nx.transpose(p) -return nx.array([dist(pe,p0,p1,ue) for pe,ue in zip(pt,u)]) -def iterable(v): -try: -len(v) -return True -except TypeError: -return False +x21 = p2[0] - p1[0] +y21 = p2[1] - p1[1] +x01 = nx.asarray(p0[0]) - p1[0] +y01 = nx.asarray(p0[1]) - p1[1] + +u = (x01*x21 + y01*y21)/float(abs(x21**2 + y21**2)) +u = nx.clip(u, 0, 1) +d = nx.sqrt((x01 - u*x21)**2 + (y01 - u*y21)**2) + +return d + def test_lines_dists(): ax = pylab.gca() - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel