SourceForge logo
SourceForge logo
Menu

[matplotlib-devel] API additions

From: Eric F. <ef...@ha...> - 2007年10月04日 00:55:52
James,
I see that you have implemented a strategy change in axes.py for 
inverted axes, with corresponding additions to the API. I don't have 
strong opinions about the strategy. Keeping track of orientation via a 
flag is reasonable, although I'm not positive it is better, given that 
it complicates the API. My first reaction to the new API is at best 
lukewarm, however, so perhaps it is worth a bit of thrashing out on the 
list.
What you have now (and similarly for yaxis):
+ def invert_xaxis(self, invert=True):
+ "Invert the x-axis if 'invert' is True."
+ self._invertedx = invert
+
+ def xaxis_inverted(self):
+ 'Returns True if the x-axis is inverted.'
+ return self._invertedx
Some alternatives:
1) Attributes (could later be properties or those terrifying traits):
 x_right=True or False
 y_up
 xdir 'right' or 'normal' or True; vs 'left' or 'reversed' or False
and similarly for ydir
2) Getters and setters:
 set_xdir() with values as some selection from above
 ydir() similar
 set_xRight(False)
 yUp(False)
Matlab uses "xdir", "reversed" etc.
I like the idea of being more descriptive, with "right"|"left" and 
"up"|"down", either as values or in the function and/or attribute names.
I also thought the old scheme of xlim(5,0) was elegant; the problem was 
that there and in related functions the variables should have been 
called "left" and "right", not "xmin" and "xmax".
I could probably come up with more possibilities, but first I want to 
see whether anyone agrees that this might be a good time to think about 
API strategy and consistency.
Eric

View entire thread

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /