Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
rcParams for default axes title location and color
--------------------------------------------------

Two new rcParams have been added: ``axes.titlelocation`` denotes the default axes title
alignment, and ``axes.titlecolor`` the default axes title color.

Valid values for ``axes.titlelocation`` are: left, center, and right.
Valid values for ``axes.titlecolor`` are: auto or a color. Setting it to auto
will fall back to previous behaviour, which is using the color in ``text.color``.
1 change: 1 addition & 0 deletions examples/style_sheets/style_sheets_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def plot_scatter(ax, prng, nb_samples=100):
x, y = prng.normal(loc=mu, scale=sigma, size=(2, nb_samples))
ax.plot(x, y, ls='none', marker=marker)
ax.set_xlabel('X-label')
ax.set_title('Axes title')
return ax


Expand Down
4 changes: 4 additions & 0 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ def set_title(self, label, fontdict=None, loc=None, pad=None,

{'fontsize': rcParams['axes.titlesize'],
'fontweight' : rcParams['axes.titleweight'],
'color' : rcParams['axes.titlecolor'],
'verticalalignment': 'baseline',
'horizontalalignment': loc}

Expand Down Expand Up @@ -199,6 +200,9 @@ def set_title(self, label, fontdict=None, loc=None, pad=None,
'fontweight': rcParams['axes.titleweight'],
'verticalalignment': 'baseline',
'horizontalalignment': loc.lower()}
titlecolor = rcParams['axes.titlecolor']
if not cbook._str_lower_equal(titlecolor, 'auto'):
default["color"] = titlecolor
if pad is None:
pad = rcParams['axes.titlepad']
self._set_title_offset_trans(float(pad))
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,7 @@ def _validate_linestyle(ls):
# axes title
'axes.titlelocation': ['center', validate_axes_titlelocation], # alignment of axes title
'axes.titleweight': ['normal', validate_string], # font weight of axes title
'axes.titlecolor': ['auto', validate_color_or_auto], # font color of axes title
'axes.titlepad': [6.0, validate_float], # pad from axes top to title in points
'axes.grid': [False, validate_bool], # display grid or not
'axes.grid.which': ['major', validate_axis_locator], # set whether the gid are by
Expand Down
7 changes: 7 additions & 0 deletions lib/matplotlib/tests/test_rcparams.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,13 @@ def test_mec_rcparams():
assert ln.get_markeredgecolor() == 'r'


def test_axes_titlecolor_rcparams():
mpl.rcParams['axes.titlecolor'] = 'r'
_, ax = plt.subplots()
title = ax.set_title("Title")
assert title.get_color() == 'r'


def test_Issue_1713(tmpdir):
rcpath = Path(tmpdir) / 'test_rcparams.rc'
rcpath.write_text('timezone: UTC', encoding='UTF-32-BE')
Expand Down
2 changes: 2 additions & 0 deletions matplotlibrc.template
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@
#axes.titlelocation : center ## alignment of the title: {left, right, center}
#axes.titlesize : large ## fontsize of the axes title
#axes.titleweight : normal ## font weight of title
#axes.titlecolor : auto ## color of the axes title, auto falls back to text.color
## as default value
#axes.titlepad : 6.0 ## pad between axes and title in points
#axes.labelsize : medium ## fontsize of the x any y labels
#axes.labelpad : 4.0 ## space between label and axis
Expand Down