Thanks to visit codestin.com
Credit goes to github.com

Skip to content

copy FontProperty objects when creating titles (fix #3327) #3328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

fcolas
Copy link

@fcolas fcolas commented Jul 30, 2014

Fix for #3327.

@jenshnielsen
Copy link
Member

Could you add a test based on your test code in #3327 ?

@tacaswell tacaswell modified the milestones: v1.5.x, v1.4.x Jul 30, 2014
@fcolas
Copy link
Author

fcolas commented Jul 30, 2014

Here it is. I created a new test file, I'm not sure if I shouldn't have put it in test_axes.py (or even somewhere else).

@jenshnielsen
Copy link
Member

Looks great. I would probably put it in test_text

@fcolas
Copy link
Author

fcolas commented Jul 30, 2014

Well, I can do that if you want, but it's really an issue in _AxesBase that created the Text instances of each title by passing the same FontProperty object (which then gets updated during an actual Axes.set_title() call).
Tell me and I'll do either way.
By the way, are there some guidelines/conventions to name the tests (didn't find them so far)?

@jenshnielsen
Copy link
Member

One of the core developers should probably decide on that @tacaswell @mdboom what do you say?
I don't think there any specific guidelines. I was going by the similarity to the test_titles in test_text which tests left and right loc of titles.

@WeatherGod
Copy link
Member

I am a little bit hesitant about this fix (at least, I wonder if it is as
complete as it should be). We currently have just one rcParam for titles.
How does this change behavior for those who may be using an rcparam context
manager to change the properties of the title? I am guessing that it should
work as expected, but I haven't dug down to see if that is the case.

On Wed, Jul 30, 2014 at 11:33 AM, Jens H Nielsen [email protected]
wrote:

One of the core developers should probably decide on that @tacaswell
https://github.com/tacaswell @mdboom https://github.com/mdboom what
do you say?
I don't think there any specific guidelines. I was going by the similarity
to the test_titles in test_text which tests left and right loc of titles.


Reply to this email directly or view it on GitHub
#3328 (comment)
.

@fcolas
Copy link
Author

fcolas commented Jul 30, 2014

I'm not too familiar with rcParam context managers but right now (unpatched) when calling cla() on a _AxesBase instance (which is done in the middle of __init__), a single FontProperty object is created using values from rcParam (axes/_base.py:898). This object was then passed on the three Text instances which means it was shared between them.
My patch is just copying this FontProperty object (after it's filled) so that manually changing some font property on one title is not propagated to the other two.
So, if my understanding of rcParam as a repository for default settings is correct, I believe there should be no issue.

@tacaswell
Copy link
Member

Only concern is that updating the axes property manager resulting in the title updating could be seen as a feature, not a bug.

This should probably get an entry in api_chages.rst at a minimum.

I would lean toward putting it in test_text.py.

We probably only need the png version of this test and can you modify the test to include the right title too?

When you change the tests please squash the commits so that we don't end up with multiple versions of these images in the repo.

@fcolas
Copy link
Author

fcolas commented Jul 30, 2014

I'm sorry, I didn't get that: how would you update the axes property manager to update the title?
(I didn't find that in the code but it's a bit huge...)

@tacaswell
Copy link
Member

By exactly the same mechanism that cause the bug, the properties are consulted at draw time

@tacaswell
Copy link
Member

Closed as this is taken care of in #3335 .

@tacaswell tacaswell closed this Aug 26, 2014
@fcolas fcolas deleted the fix#3327 branch September 1, 2014 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants