Re: [Matplotlib-users] [SciPy-user] (Mac) Close a plot window, crash IPython?
hi, i observed a similar problem that persists in matplotlib 0.90.1 (python 2.5, numpy 1.0.1, ipython 0.7.3). the problem occurs when a window is closed and it seems to be specific to the non-interactive mode using the GTK or GTKAgg backend. the following short script runs ok once, but when i try to run it a second time, python hangs: # start script import pylab as P P.ioff() P.figure() P.close() # stop script this is probably a problem of matplotlib and we should continue this thread on the matplotlib email list. cheers, kilian From: John Hunter [EMAIL PROTECTED] Date: July 13, 2007 1:10:35 PM PDT To: SciPy Users List [EMAIL PROTECTED] Subject: Re: [SciPy-user] (Mac) Close a plot window, crash IPython? Reply-To: SciPy Users List [EMAIL PROTECTED] On 7/13/07, David Warde-Farley [EMAIL PROTECTED] wrote: It does seem as though the *exact* same bug was reported today on matplotlib-devel (what are the odds?), I shall checkout the svn version and see if that fixes it, and make them aware of the other WX- related bug as well. I hope this does fix your problem, but the bug that was fixed was also recently introduced (in a svn commit after the 0.90.1 release) so it may not be your problem. But if you can update from svn and see if the problem is still there, that would be a great start. See you on the matplotlib-devel side :-) JDH ___ SciPy-user mailing list [EMAIL PROTECTED] http://projects.scipy.org/mailman/listinfo/scipy-user - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Core-dump when (mis)using scale_transform
Hi, I've been using matplotlib for a little while and am finding it very useful. Yesterday, though, I hit a problem: Because I didn't read the docs properly, I tried to use matplotlib.transforms.scale_transform like this: t = scale_transform(1.0, 2.0) but then I got a core-dump when trying to use it: from matplotlib.transforms import scale_transform t = scale_transform(1.0, 2.0) print t.xy_tup((1.0, 0.2)) What I should have done was this, which works: from matplotlib.transforms import scale_transform, Value t = scale_transform(Value(1.0), Value(2.0)) print t.xy_tup((1.0, 0.2)) The function _transforms_module::new_affine() in _transforms.cpp does contain checks that its args are LazyValue objects, but it seems to ignore the results. The following patch (against 0.90.1) makes the constructor throw a TypeError if it doesn't get what it wants. (It also fixes a small typo in a separate error string.) --- ORIG/_transforms.cpp2007-07-17 10:10:37.443202000 +0100 +++ NEW/_transforms.cpp 2007-07-17 10:11:00.257365000 +0100 @@ -42,7 +42,7 @@ int LazyValue::compare(const Py::Object other) { if (!check(other)) -throw Py::TypeError(Can on compare LazyValues with LazyValues); +throw Py::TypeError(Can only compare LazyValues with LazyValues); LazyValue* pother = static_castLazyValue*(other.ptr()); double valself = val(); double valother = pother-val(); @@ -2116,12 +2116,13 @@ args.verify_length(6); - LazyValue::check(args[0]); - LazyValue::check(args[1]); - LazyValue::check(args[2]); - LazyValue::check(args[3]); - LazyValue::check(args[4]); - LazyValue::check(args[5]); + if (!LazyValue::check(args[0]) + || !LazyValue::check(args[1]) + || !LazyValue::check(args[2]) + || !LazyValue::check(args[3]) + || !LazyValue::check(args[4]) + || !LazyValue::check(args[5])) + throw Py::TypeError(Affine(a, b, c, d, tx, ty) expected 6 LazyValue args); LazyValue* a = static_castLazyValue*(args[0].ptr()); LazyValue* b = static_castLazyValue*(args[1].ptr()); Would this be worth applying? By the look of the code in transform.py, translation_transform() and possibly others might be affected by this too. Maybe a better solution might be to automatically construct Value objects from Python floats where required, but that might need a bit more thought. Ben. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Core-dump when (mis)using scale_transform
Thanks for tracking this down, Ben. Applied in svn as r3547. Ben North wrote: I've been using matplotlib for a little while and am finding it very useful. Yesterday, though, I hit a problem: - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] ImportError: matplotlib/ft2font.so: undefined symbol: PyUnicodeUCS4_GetSize
Hi everyone, I'm running Suse10.2 and installing packages using Yast (after much pain trying to install Numpy and Scipy without it!). After installing (and re-installing) Matplotlib in this way, I get the error, ImportError: matplotlib/ft2font.so: undefined symbol: PyUnicodeUCS4_GetSize when I attempt to import pylab. Can anybody help me fix this? I couldn't find any help on the matplotlib site and my .matplotlib directory is empty. Oh, I'm also a bit new to Linux - please be patient! Thanks in advance, Mark. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Question about default value for 'emit' in set_[xy]lim()
Hi, The normal rectangular Axes class and the derived PolarAxes class both have set_xlim() and set_ylim() functions, but the rectangular Axes class has a default value of False for the 'emit' argument, whereas the PolarAxes version has True. I had a figure containing three Axes instances, arranged as one 'main' plot and two subsidiary plots. I wanted the subsidiary plots to have their x- and y-limits slaved to changes in the main plot's, but with the current default value of 'emit', I wasn't getting callbacks when I used the navigation toolbar to pan/zoom around the main plot. Would there be any disadvantage to changing the default value to True, as in the patch below? (I haven't looked at all callers of set_xlim() so I could well be missing a good reason why this isn't currently done.) Thanks, Ben. - - - - 8 - - - - --- ORIG/axes.py2007-07-17 15:24:10.367402000 +0100 +++ NEW/axes.py 2007-07-17 15:48:28.708471000 +0100 @@ -1449,7 +1449,7 @@ return self.viewLim.intervalx().get_bounds() -def set_xlim(self, xmin=None, xmax=None, emit=False, **kwargs): +def set_xlim(self, xmin=None, xmax=None, emit=True, **kwargs): set_xlim(self, *args, **kwargs): @@ -1573,7 +1573,7 @@ 'Get the y axis range [ymin, ymax]' return self.viewLim.intervaly().get_bounds() -def set_ylim(self, ymin=None, ymax=None, emit=False, **kwargs): +def set_ylim(self, ymin=None, ymax=None, emit=True, **kwargs): set_ylim(self, *args, **kwargs): - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] ImportError: matplotlib/ft2font.so: undefined symbol: PyUnicodeUCS4_GetSize
I recently ran into a similar problem myself building stuff from source, but I'm not sure of the specifics with SuSE and their packages etc. Python can be configured in two ways -- with two-byte (UCS2) or four-byte (UCS4) Unicode characters. Apparently the default for a source installation of Python is UCS2, but many (most) Linux distributions build it for UCS4. Python extensions built for one configuration can not be used with a Python built for the other configuration. When Python extensions are built, if all goes well, they will match the configuration of the Python interpreter. It looks like somehow you have a mismatch between matplotlib and your Python interpreter. If you installed everything from packages, I would expect them all to match (unless SuSE's quality control has really gone down as of late ;). Perhaps something is still around from when you built things from source. Did you at any point build your own Python? On a number of Linux distributions (probably including SuSE, but I don't know for sure), things installed from source are under the /usr/local tree. To diagnose this, you could see if anything is getting pulled in from there (rather than from the packaged stuff, which wouldn't be under /usr/local). For instance whereis python, will tell you which python is being used. When you import a Python module, you can use __file__ to see where it was imported from. For example: import pylab pylab.__file__ Hope that at least offers some next steps for tracking this down. Cheers, Mike mark starnes wrote: Hi everyone, I'm running Suse10.2 and installing packages using Yast (after much pain trying to install Numpy and Scipy without it!). After installing (and re-installing) Matplotlib in this way, I get the error, ImportError: matplotlib/ft2font.so: undefined symbol: PyUnicodeUCS4_GetSize when I attempt to import pylab. Can anybody help me fix this? I couldn't find any help on the matplotlib site and my .matplotlib directory is empty. Oh, I'm also a bit new to Linux - please be patient! Thanks in advance, Mark. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Question about default value for 'emit' in set_[xy]lim()
On 7/17/07, Ben North [EMAIL PROTECTED] wrote: Hi, The normal rectangular Axes class and the derived PolarAxes class both have set_xlim() and set_ylim() functions, but the rectangular Axes class has a default value of False for the 'emit' argument, whereas the PolarAxes version has True. looked at all callers of set_xlim() so I could well be missing a good reason why this isn't currently done.) This inconsistency was never intentional, and is fixed in svn. JDH - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Difference in Axes.hlines / Axes.vlines
Hi, There is a difference in the behaviour of Axes.hlines() vs Axes.vlines(), in that vlines() lets you supply scalars for ymin and ymax, whereas hlines() doesn't (for xmin and xmax). The patch below fixes that, and also what looks like a separate bug in vlines. There are also other differences, around units, but I haven't worked with that area of matplotlib so will leave that for others. I was wondering, though, whether there'd be any support for some work which tidied up the near-duplicate code in axes.py. I've been playing around with an approach using python's metaclass support, which, for example, would replace the definitions of the two near-identical functions set_xscale() and set_yscale() with the one meta-definition: @MC_Traited.construct_traited_variants def set__AXISLETTER_scale(self, value, base_AXISLETTER_ = 10, subs_AXISLETTER_ = None): SET_%(axis_letter_UC)sSCALE(value, base%(axis_letter)s = 10, subs%(axis_letter)s = None) Set the %(axis_letter)s-scaling: 'log' or 'linear' If value is 'log', the additional kwargs have the following meaning * base%(axis_letter)s: base of the logarithm * subs%(axis_letter)s: a sequence of the location of the minor ticks; None defaults to autosubs, which depend on the number of decades in the plot. Eg for base 10, subs%(axis_letter)s = (1, 2, 5) will put minor ticks on 1, 2, 5, 11, 12, 15, 21, To turn off minor ticking, set subs%(axis_letter)s = [] ACCEPTS: ['log' | 'linear'] assert(value.lower() in ('log', 'linear')) my_axis = _TRAITS_.my_axis(self) if value == 'log': my_axis.set_major_locator(LogLocator(base_AXISLETTER_)) my_axis.set_major_formatter(LogFormatterMathtext(base_AXISLETTER_)) my_axis.set_minor_locator(LogLocator(base_AXISLETTER_, subs_AXISLETTER_)) _TRAITS_.get_my_func(self.transData).set_type(LOG10) minval, maxval = _TRAITS_.get_my_lim(self) if min(minval, maxval) = 0: self.autoscale_view() elif value == 'linear': my_axis.set_major_locator(AutoLocator()) my_axis.set_major_formatter(ScalarFormatter()) my_axis.set_minor_locator(NullLocator()) my_axis.set_minor_formatter(NullFormatter()) _TRAITS_.get_my_func(self.transData).set_type(IDENTITY) I haven't quite worked through the details, but it looks like it would cut nearly 400 lines off axes.py (while adding c.200 lines of supporting code), as well as avoid the type of inconsistency seen in hlines/vlines. If there's interest, I'll post what I've got so far for comments. Thanks, Ben. - - - - 8 - - - - --- ORIG/axes.py2007-07-17 15:24:10.367402000 +0100 +++ NEW/axes.py 2007-07-17 15:38:03.705394000 +0100 @@ -2325,6 +2325,11 @@ xmin = asarray(xmin) xmax = asarray(xmax) +if len(xmin)==1: +xmin = xmin*ones(y.shape, typecode(y)) +if len(ymax)==1: +xmax = xmax*ones(y.shape, typecode(y)) + if len(xmin)!=len(y): raise ValueError, 'xmin and y are unequal sized sequences' @@ -2418,7 +2423,7 @@ minx = nx.amin(x) maxx = nx.amax(x) miny = min(nx.amin(ymin), nx.amin(ymax)) -maxy = max(nx.amax(ymax), nx.amax(ymax)) +maxy = max(nx.amax(ymin), nx.amax(ymax)) minx, maxx = self.convert_xunits((minx, maxx)) miny, maxy = self.convert_yunits((miny, maxy)) corners = (minx, miny), (maxx, maxy) - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] pytz, dateutil not getting installed from svn build
For some reason, builds from SVN dont install either pytz or dateutil (at least not in the right place). Importing pylab from these builds results in an import error. How can I build these so as to convince these modules to install correctly? Thanks. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Problem to show new plots.
Hello, I wrote a message some weeks ago about a problem I have with pylab, but I think I probably did not explained it very well. I am witting a small application that use tkFileDialog to prompt user to select a file. Then reads it and plot the data. I want that the user could be able to press a key and read another file, to plot it again together with the previous one(s). The problem is that the thee graph is not drawn until I resize the window. Even if I use the draw() method. Any help will be appreciated. Thanks in advance. Angel. code: import sys import os import time import tkFileDialog import pylab pylab.hold(1) path='E:\\Nima' n=0 def click(event): print 'click on: ', event.xdata, event.ydata def keyp(event): global path if event.key.lower()=='o': fin = tkFileDialog.askopenfilename(initialdir=path) path=os.path.split(fin)[0] plot2(fin) def plot2(fin): global myplot global n f=file(fin, 'r') lines=f.readlines() f.close() X=[] Y=[] for line in lines[1:]: line=line.replace(',', '.') X.append(float(line.split('\t')[2])) Y.append(float(line.split('\t')[5])) l,=myplot.plot(X, Y, label=os.path.split(fin)[1]) myplot.legend() if n==0: print showing... n=1 pylab.show() l.set_visible(1) myplot.draw() if __name__=='__main__': myplot=pylab.subplot(111) myplot.grid() kid=pylab.connect('key_press_event', keyp) pylab.xlabel('Area [A2/molecule]') pylab.ylabel('SP [mN/m]') fin = tkFileDialog.askopenfilename(initialdir=path) path=os.path.split(fin)[0] plot2(fin) - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Difference in Axes.hlines / Axes.vlines
On 7/17/07, Ben North [EMAIL PROTECTED] wrote: There is a difference in the behaviour of Axes.hlines() vs Axes.vlines(), in that vlines() lets you supply scalars for ymin and ymax, whereas hlines() doesn't (for xmin and xmax). The patch below fixes that, and also what looks like a separate bug in vlines. There are also other differences, around units, but I haven't worked with that area of matplotlib so will leave that for others. Thanks for catching that -- I recently introduced this bug when I numpified the axes module. Fixed in svn I was wondering, though, whether there'd be any support for some work which tidied up the near-duplicate code in axes.py. I've been playing Certainly, but probably not using meta-classes. around with an approach using python's metaclass support, which, for example, would replace the definitions of the two near-identical functions set_xscale() and set_yscale() with the one meta-definition: @MC_Traited.construct_traited_variants def set__AXISLETTER_scale(self, value, base_AXISLETTER_ = 10, subs_AXISLETTER_ = None): SET_%(axis_letter_UC)sSCALE(value, base%(axis_letter)s = 10, subs%(axis_letter)s = None) I'm disinclined to use python black magic -- I find it makes the code harder to grok for the typical scientist, and these are our main developers. Most of these guys are still trying to figure out what a class is wink But there are other ways to reduce code duplication that are not as clever def set_xscale(self, value, basex = 10, subsx=None): self._set_scale(axis=self.xaxis, transfunc=self.transData.get_funcx(), limfunc=self.get_xlim, value=value, base=basex, subse=subsx) def set_yscale(self, value, basex = 10, subsx=None): self._set_scale(axis=self.yaxis, transfunc=self.transData.get_funcy(), limfunc=self.get_ylim, value=value, base=basey, subse=subsy) def _set_scale(self, axis, transfunc, limfunc, value, basex = 10, subsx=None): assert(value.lower() in ('log', 'linear', )) if value == 'log': axis.set_major_locator(mticker.LogLocator(base)) axis.set_major_formatter(mticker.LogFormatterMathtext(base)) axis.set_minor_locator(mticker.LogLocator(base,subsx)) transfunc.set_type(mtrans.LOG10) minx, maxx = limfunc() if min(minx, maxx)=0: self.autoscale_view() elif value == 'linear': axis.set_major_locator(mticker.AutoLocator()) axis.set_major_formatter(mticker.ScalarFormatter()) axis.set_minor_locator(mticker.NullLocator()) axis.set_minor_formatter(mticker.NullFormatter()) transfunc.set_type( mtrans.IDENTITY ) which I definitely encourage. There may be something more elegant than this, but we only try to be a little clever. Get too clever, and Darren and Eric will yell at you. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Difference in Axes.hlines / Axes.vlines
On Tuesday 17 July 2007 12:04:54 pm John Hunter wrote: I was wondering, though, whether there'd be any support for some work which tidied up the near-duplicate code in axes.py. I've been playing Certainly, but probably not using meta-classes. around with an approach using python's metaclass support, which, for example, would replace the definitions of the two near-identical functions set_xscale() and set_yscale() with the one meta-definition: @MC_Traited.construct_traited_variants def set__AXISLETTER_scale(self, value, base_AXISLETTER_ = 10, subs_AXISLETTER_ = None): SET_%(axis_letter_UC)sSCALE(value, base%(axis_letter)s = 10, subs%(axis_letter)s = None) I'm disinclined to use python black magic -- I find it makes the code harder to grok for the typical scientist, and these are our main developers. Most of these guys are still trying to figure out what a class is wink It's true. That bit of code looks like Perl to me. Darren - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] pytz, dateutil not getting installed from svn build
On 7/17/07, Chris Fonnesbeck [EMAIL PROTECTED] wrote: For some reason, builds from SVN dont install either pytz or dateutil (at least not in the right place). Importing pylab from these builds results in an import error. How can I build these so as to convince these modules to install correctly? This is typically caused when the install process detects that pytz and dateutil are already installed, and so doesn't overright them. My guess is that they were available in your PYTHONPATH at install time but not at run time. So at install time they are detected and not installed, but at run time they cannot be found. If this is the solution, you need to build and run in the same environment, or blow away existing copies of pytz and dateutil whereever they are lurking and then reinstall mpl. Use the __file__ module attr to poke around and see if you can find them. JDH - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users