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

Skip to content

Commit dffac7a

Browse files
committed
Merge pull request matplotlib#1764 from WeatherGod/mplot3d/set_title
Make loc come after fontdict in set_title. Closes matplotlib#1759
2 parents 8ec9555 + 0a1fb04 commit dffac7a

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

examples/mplot3d/lorenz_attractor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def lorenz(x, y, z, s=10, r=28, b=2.667) :
4444
ax.set_xlabel("X Axis")
4545
ax.set_ylabel("Y Axis")
4646
ax.set_zlabel("Z Axis")
47+
ax.set_title("Lorenz Attractor")
4748

4849
plt.show()
4950

lib/matplotlib/axes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3184,7 +3184,7 @@ def get_title(self, loc="center"):
31843184
return title.get_text()
31853185

31863186
@docstring.dedent_interpd
3187-
def set_title(self, label, loc="center", fontdict=None, **kwargs):
3187+
def set_title(self, label, fontdict=None, loc="center", **kwargs):
31883188
"""Set a title for the axes.
31893189
31903190
Set one of the three available axes titles. The available titles
@@ -3195,14 +3195,14 @@ def set_title(self, label, loc="center", fontdict=None, **kwargs):
31953195
----------
31963196
label : str
31973197
Text to use for the title
3198-
loc : {'center', 'left', 'right'}, str, optional
3199-
Which title to set, defaults to 'center'
32003198
fontdict : dict
32013199
A dictionary controlling the appearance of the title text,
32023200
the default `fontdict` is:
32033201
{'fontsize': rcParams['axes.titlesize'],
32043202
'verticalalignment': 'baseline',
32053203
'horizontalalignment': loc}
3204+
loc : {'center', 'left', 'right'}, str, optional
3205+
Which title to set, defaults to 'center'
32063206
32073207
Returns
32083208
-------

lib/matplotlib/pyplot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ def box(on=None):
11861186

11871187
def title(s, *args, **kwargs):
11881188
"""
1189-
title(label, loc='center', fontdict=None, **kwargs)
1189+
title(label, fontdict=None, loc='center', **kwargs)
11901190
11911191
Set a title of the current axes.
11921192
@@ -1198,14 +1198,14 @@ def title(s, *args, **kwargs):
11981198
----------
11991199
label : str
12001200
Text to use for the title
1201-
loc : {'center', 'left', 'right'}, str, optional
1202-
Which title to set, defaults to 'center'
12031201
fontdict : dict
12041202
A dictionary controlling the appearance of the title text,
12051203
the default `fontdict` is:
12061204
{'fontsize': rcParams['axes.titlesize'],
12071205
'verticalalignment': 'baseline',
12081206
'horizontalalignment': loc}
1207+
loc : {'center', 'left', 'right'}, str, optional
1208+
Which title to set, defaults to 'center'
12091209
12101210
Returns
12111211
-------

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2360,10 +2360,12 @@ def bar3d(self, x, y, z, dx, dy, dz, color='b',
23602360

23612361
self.auto_scale_xyz((minx, maxx), (miny, maxy), (minz, maxz), had_data)
23622362

2363-
def set_title(self, label, fontdict=None, **kwargs):
2364-
Axes.set_title(self, label, fontdict, **kwargs)
2363+
def set_title(self, label, fontdict=None, loc='center', **kwargs):
2364+
ret = Axes.set_title(self, label, fontdict=fontdict, loc=loc, **kwargs)
23652365
(x, y) = self.title.get_position()
23662366
self.title.set_y(0.92 * y)
2367+
return ret
2368+
set_title.__doc__ = maxes.Axes.set_title.__doc__
23672369

23682370
def get_test_data(delta=0.05):
23692371
'''

0 commit comments

Comments
 (0)