Automatic placement of a text box? ie empty legend [matplotlib]
The automatic placement functionality of legend() is nice. I'd like to make use of it to place a box with just a title or title and comment (ie, some text) but no lines or legend entries. Does anyone know a way to do this? -- http://mail.python.org/mailman/listinfo/python-list
Simple legend code no longer works after upgrade to Ubuntu 11.10
rom pylab import * plot([0,0],[1,1],label='Ubuntu 11.10') Before I upgraded to 2.7.2+ / 4 OCt 2011, the following code added a comment line with a legend. Now, the same code makes the legend appear "off-screen", ie way outside the axes limits. Can anyone help? And/or is there a new way to add a title and footer to the legend? Thanks! lh=legend(fancybox=True,shadow=False) lh.get_frame().set_alpha(0.5) from matplotlib.offsetbox import TextArea, VPacker fontsize=lh.get_texts()[0].get_fontsize() legendcomment=TextArea('extra comments here', textprops=dict(size=fontsize)) show() # Looks fine here lh._legend_box = VPacker(pad=5, sep=0, children=[lh._legend_box,legendcomment], align="left") lh._legend_box.set_figure(gcf()) draw() -- http://mail.python.org/mailman/listinfo/python-list
Simple legend code no longer works after upgrade to Ubuntu 11.10
""" Before I upgraded to 2.7.2+ / 4 OCt 2011, the following code added a comment line to an axis legend using matplotlib / pylab. Now, the same code makes the legend appear "off-screen", ie way outside the axes limits. Can anyone help? And/or is there a new way to add a title and footer to the legend? Thanks! """ from pylab import * plot([0,0],[1,1],label='Ubuntu 11.10') lh=legend(fancybox=True,shadow=False) lh.get_frame().set_alpha(0.5) from matplotlib.offsetbox import TextArea, VPacker fontsize=lh.get_texts()[0].get_fontsize() legendcomment=TextArea('extra comments here', textprops=dict(size=fontsize)) show() # Looks fine here lh._legend_box = VPacker(pad=5, sep=0, children=[lh._legend_box,legendcomment], align="left") lh._legend_box.set_figure(gcf()) draw() -- http://mail.python.org/mailman/listinfo/python-list
Bug in fixed_point?!
I cannot figure out what I'm doing wrong. The following does not return a fixed point: from scipy import optimize xxroot= optimize.fixed_point(lambda xx: exp(-2.0*xx)/2.0, 1.0, args=(), xtol=1e-12, maxiter=500) print ' %f solves fixed point, ie f(%f)=%f ?'% (xxroot,xxroot,exp(-2.0*xxroot)/2.0) Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in fixed_point?!
On Dec 21, 9:36 am, Robert Kern wrote: > When you do, please provide the information that Terry Reedy asked for. > Sorry; quite right. For completeness I'll post here as well as over on scipy. Here's the actual code: - from scipy import optimize from math import exp xxroot= optimize.fixed_point(lambda xx: exp(-2.0*xx)/2.0, 1.0, args=(), xtol=1e-12, maxiter=500) print ' %f solves fixed point, ie f(%f)=%f ?'% (xxroot,xxroot,exp(-2.0*xxroot)/2.0) Here is the output -- Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56) In [1]: run tmp.py 0.332058 solves fixed point, ie f(0.332058)=0.257364 ? -- http://mail.python.org/mailman/listinfo/python-list
weighted mean; weighted standard error of the mean (sem)
I am looking for some reaally basic statistical tools. I have some sample data, some sample weights for those measurements, and I want to calculate a mean and a standard error of the mean. Here are obvious places to look: numpy scipy.stats statsmodels It seems to me that numpy's "mean" and "average" functions have their names backwards. That is, often a mean is defined more generally than average, and includes the possibility of weighting, but in this case it is "average" that has a weights argument. Can these functions be merged/renamed/deprecated in the future? It's clear to me that "mean" should allow for weights. None of these modules, above, offer standard error of the mean which incorporates weights. numpy's "sem" doesn't, and that's the closest thing. numpy's "var" doesn't allow weights. There aren't any weighted variances in the above modules. Again, are there favoured codes for these functions? Can they be incorporated appropriately in the future? Most immediately, I'd love to get code for weighted sem. I'll write it otherwise, but if I do I'd love to know whom to bug to get it incorporated into numpy.sem ... Thanks! None of them have this basic function. Has anyone written one? -- http://mail.python.org/mailman/listinfo/python-list
Re: weighted mean; weighted standard error of the mean (sem)
> The best place to ask about numpy related stuff is the numpy mailing list at: > > http://mail.scipy.org/mailman/listinfo/numpy-discussion > > This is also the best place to present a patch if you have code to > contribute. In my experience the numpy devs are always happy to have > new contributors, but be sure to discuss the problem first, as the > folk over there might be able to provide a solution which doesn't > require a new patch. Thanks, Tim, Ooops -- the sem() I mentioned is sciypy.stats.sem, not in numpy... Does your advice hold? Thanks, c -- http://mail.python.org/mailman/listinfo/python-list
"pointlabel"-like function for Python: distribute text labels on a 2-d scatter plot to avoid overlapping labels
Hello. There is a function for R (http://bm2.genes.nig.ac.jp/RGM2/ R_current/library/maptools/man/pointLabel.html) to help with placing/ locating text labels in an optimized way so as to minimise some measure of text overlap (or likely text overlap). Has anyone written or ported such a thing for Python? Thanks, c -- http://mail.python.org/mailman/listinfo/python-list
Re: "pointlabel"-like function for Python: distribute text labels on a 2-d scatter plot to avoid overlapping labels
> measure of text overlap (or likely text overlap). Has anyone written > or ported such a thing for Python? Hm (talking to myself)... the link I gave above has some references, and one of those includes some python code. Seems not packaged up yet for plots, but may be close: http://meta.wikimedia.org/wiki/Map_generator#Placing_labels Anything better? c -- http://mail.python.org/mailman/listinfo/python-list