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

Skip to content

Commit 697cd6f

Browse files
committed
Merge pull request matplotlib#3335 from fcolas/newfix#3327
BUG : use copy of font-properties for each axes title closes matplotlib#3327
2 parents 05042c5 + 4782426 commit 697cd6f

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -908,12 +908,12 @@ def cla(self):
908908
)
909909
self._left_title = mtext.Text(
910910
x=0.0, y=1.0, text='',
911-
fontproperties=props,
911+
fontproperties=props.copy(),
912912
verticalalignment='baseline',
913913
horizontalalignment='left', )
914914
self._right_title = mtext.Text(
915915
x=1.0, y=1.0, text='',
916-
fontproperties=props,
916+
fontproperties=props.copy(),
917917
verticalalignment='baseline',
918918
horizontalalignment='right',
919919
)

lib/matplotlib/tests/test_text.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,16 @@ def test_alignment():
197197
ax.set_yticks([])
198198

199199

200+
@image_comparison(baseline_images=['axes_titles'], extensions=['png'])
201+
def test_axes_titles():
202+
# Related to issue #3327
203+
fig = plt.figure()
204+
ax = plt.subplot(1,1,1)
205+
ax.set_title('center', loc='center', fontsize=20, fontweight=700)
206+
ax.set_title('left', loc='left', fontsize=12, fontweight=400)
207+
ax.set_title('right', loc='right', fontsize=12, fontweight=400)
208+
209+
200210
@cleanup
201211
def test_set_position():
202212
fig, ax = plt.subplots()

0 commit comments

Comments
 (0)