SourceForge logo
SourceForge logo
Menu

matplotlib-devel

From: Evans, J. R <jam...@jp...> - 2009年01月29日 22:46:21
Is there a reason why Axis.get_label returns the label as a Text instance, or should there really be set_label/get_label methods that takes a string and set the text value of the Text instance and returns the string value of the Text instance?
Everywhere it is used in the code it is used in a two-step process to really just get and set the string value of the Text instance.
--James Evans
From: John H. <jd...@gm...> - 2009年01月30日 12:40:47
On Thu, Jan 29, 2009 at 3:30 PM, Evans, James R
<jam...@jp...> wrote:
> Is there a reason why Axis.get_label returns the label as a Text instance, or should there really be set_label/get_label methods that takes a string and set the text value of the Text instance and returns the string value of the Text instance?
>
> Everywhere it is used in the code it is used in a two-step process to really just get and set the string value of the Text instance.
I don't think there is an easy answer to this one. Many of the axis
getters return either artists or lists of artists, so I am
disinclined to change the behavior since it does what it is documented
to do and it is a minor inconvenience to have to "get_text". The end
user might just as well want to set the font color, so returning the
text instance facilitates that. What makes it trickier is that
"label" is overloaded here, as all artists have a label property (eg
the legend uses the label property for autolegending) which *is* a
simple string. It's a bit more confusing still because the Axes
accessor methods *do* convert these labels to strings, eg
ax.get_xlabel and ax.get_xticklabels.
To solve the label property clash, a better name would probably be
"axislabel" or something like that, but I'm -0 on doing anything about
it since in practice noone is using the label property in this way
(though someone may want to down the road) . If there is a compelling
use case for fixing it I'm amenable, but it looks more like a wart
that is worth keeping rather than breaking someone's code is a way
that may take them a while to figure out.
JDH
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 によって変換されたページ (->オリジナル) /