You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The goal would be to set any text properties like rotation, alignment, rotation_mode on the ticklabels just as it is possible with cartesian axes and as it was possible with polar axes.
Currently the problem is that the text on the graph is ticklabels which is not defined as a text whose rotation can be modified. Normally the text whose rotation can be modified is defined in text.py but when creating the ticks the label is not created with this type. We can use the set_rotation because when the label is creat by the user the label is bind on the text.py type with set_ticklabels in axis.py. I think this ask creators to refactor the code design. I am sure about this because if in text.py in init you add a default value, when you creat ticks.label the rotation value is not the default one.
text.py :
def init(self,
x=0, y=0, text='',
color=None, # defaults to rc params
verticalalignment='baseline',
horizontalalignment='left',
multialignment=None,
fontproperties=None, # defaults to FontProperties()
rotation=92,
linespacing=None,
rotation_mode=None,
usetex=None, # defaults to rcParams['text.usetex']
wrap=False,
**kwargs
):
"""
Create a :class:~matplotlib.text.Text instance at x, y
with string text.
Valid kwargs are
%(Text)s
"""
Artist.__init__(self)
self._x, self._y = x, y
if color is None:
color = rcParams['text.color']
if fontproperties is None:
fontproperties = FontProperties()
elif isinstance(fontproperties, six.string_types):
fontproperties = FontProperties(fontproperties)
self.set_text(text)
self.set_color(color)
self.set_usetex(usetex)
self.set_wrap(wrap)
self._verticalalignment = verticalalignment
self._horizontalalignment = horizontalalignment
self._multialignment = multialignment
self.set_rotation(rotation)
self._fontproperties = fontproperties
self._bbox_patch = None # a FancyBboxPatch instance
self._renderer = None
if linespacing is None:
linespacing = 1.2 # Maybe use rcParam later.
self._linespacing = linespacing
self.set_rotation_mode(rotation_mode)
self.update(kwargs)
I think this ask creators to refactor the code design.
@Aclant Yes this is somehow the definition of a GitHub issue.
You may print type(label) to see that the labels are indeed matplotlib.text.Text instances. Their properties can be changed as usual with .set_<property>. The problem here is that those settings are reverted once they are drawn according to a general property set within the axis class.
This has been introduced deliberately to easily produce rotated labels by default, however it now prevents modifying them individually.
I would guess that people are well aware of the cause of this issue; the only question would be on how to allow for individual settings without throwing all the nice automatic labeling in the bin.
@tacaswell A final example: As I see it this issue is a regression to 2.0.2. However there seem to have been a reason to make the changes that led to this, implicitely removing the option to rotate labels and without notifying about workarounds. So while technically I would be able to fix this, I cannot do it because it's unclear how those changes are meant to be preserved in the intended usecase while still allowing for the rotated ticklabels. In case there were clear instructions here I could surely fix this and it could be backported as a regression fix.
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
Activity
ImportanceOfBeingErnest commentedon Mar 29, 2018
I think this is also related to #10105 where alignment is ignored.
At the end it might all be related to #9068 or #9881?
QuLogic commentedon Mar 30, 2018
What's the end goal exactly? There are some workarounds, depending on what you want to do.
ImportanceOfBeingErnest commentedon Mar 30, 2018
The goal would be to set any text properties like rotation, alignment, rotation_mode on the ticklabels just as it is possible with cartesian axes and as it was possible with polar axes.
Aclant commentedon Mar 31, 2018
Currently the problem is that the text on the graph is ticklabels which is not defined as a text whose rotation can be modified. Normally the text whose rotation can be modified is defined in text.py but when creating the ticks the label is not created with this type. We can use the set_rotation because when the label is creat by the user the label is bind on the text.py type with set_ticklabels in axis.py. I think this ask creators to refactor the code design. I am sure about this because if in text.py in init you add a default value, when you creat ticks.label the rotation value is not the default one.
text.py :
def init(self,
x=0, y=0, text='',
color=None, # defaults to rc params
verticalalignment='baseline',
horizontalalignment='left',
multialignment=None,
fontproperties=None, # defaults to FontProperties()
rotation=92,
linespacing=None,
rotation_mode=None,
usetex=None, # defaults to rcParams['text.usetex']
wrap=False,
**kwargs
):
"""
Create a :class:
~matplotlib.text.Textinstance at x, ywith string text.
ImportanceOfBeingErnest commentedon Apr 1, 2018
@Aclant Yes this is somehow the definition of a GitHub issue.
You may print
type(label)to see that the labels are indeedmatplotlib.text.Textinstances. Their properties can be changed as usual with.set_<property>. The problem here is that those settings are reverted once they are drawn according to a general property set within the axis class.This has been introduced deliberately to easily produce rotated labels by default, however it now prevents modifying them individually.
I would guess that people are well aware of the cause of this issue; the only question would be on how to allow for individual settings without throwing all the nice automatic labeling in the bin.
ImportanceOfBeingErnest commentedon May 3, 2018
@tacaswell A final example: As I see it this issue is a regression to 2.0.2. However there seem to have been a reason to make the changes that led to this, implicitely removing the option to rotate labels and without notifying about workarounds. So while technically I would be able to fix this, I cannot do it because it's unclear how those changes are meant to be preserved in the intended usecase while still allowing for the rotated ticklabels. In case there were clear instructions here I could surely fix this and it could be backported as a regression fix.
ImportanceOfBeingErnest commentedon Jun 5, 2018
Related to this: It is equally not possible to set the font-weight to the ticklabels.
Suppose we want to make the radial ticklabels of a polar plot bold (like in this SO question). In matplotlib 2.0 you could do
This doesn't work any more due to the changes made in #9068 or #9881.
Alternatively I though one could use
which works for circular polar plots, but
So there is currently no way to make the rticklabels of a polar plot bold.
1 remaining item
github-actions commentedon May 2, 2023
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
gonzabk commentedon Jul 27, 2023
Having the same problem on july 2023 :)
melissawm commentedon Aug 8, 2023
I will reopen until we can discuss what's the best strategy here - feel free to close if it's not actionable.