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