| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3ae55e1 commit f529ced
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,9 @@ | |||
| 1 | + rcParams for default axes title location and color | ||
| 2 | + -------------------------------------------------- | ||
| 3 | + | ||
| 4 | + Two new rcParams have been added: ``axes.titlelocation`` denotes the default axes title | ||
| 5 | + alignment, and ``axes.titlecolor`` the default axes title color. | ||
| 6 | + | ||
| 7 | + Valid values for ``axes.titlelocation`` are: left, center, and right. | ||
| 8 | + Valid values for ``axes.titlecolor`` are: auto or a color. Setting it to auto | ||
| 9 | + will fall back to previous behaviour, which is using the color in ``text.color``. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,6 +23,7 @@ def plot_scatter(ax, prng, nb_samples=100): | |||
| 23 | 23 | x, y = prng.normal(loc=mu, scale=sigma, size=(2, nb_samples)) | |
| 24 | 24 | ax.plot(x, y, ls='none', marker=marker) | |
| 25 | 25 | ax.set_xlabel('X-label') | |
| 26 | + ax.set_title('Axes title') | ||
| 26 | 27 | return ax | |
| 27 | 28 | ||
| 28 | 29 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -164,6 +164,7 @@ def set_title(self, label, fontdict=None, loc=None, pad=None, | |||
| 164 | 164 | ||
| 165 | 165 | {'fontsize': rcParams['axes.titlesize'], | |
| 166 | 166 | 'fontweight' : rcParams['axes.titleweight'], | |
| 167 | + 'color' : rcParams['axes.titlecolor'], | ||
| 167 | 168 | 'verticalalignment': 'baseline', | |
| 168 | 169 | 'horizontalalignment': loc} | |
| 169 | 170 | ||
@@ -199,6 +200,9 @@ def set_title(self, label, fontdict=None, loc=None, pad=None, | |||
| 199 | 200 | 'fontweight': rcParams['axes.titleweight'], | |
| 200 | 201 | 'verticalalignment': 'baseline', | |
| 201 | 202 | 'horizontalalignment': loc.lower()} | |
| 203 | + titlecolor = rcParams['axes.titlecolor'] | ||
| 204 | + if not cbook._str_lower_equal(titlecolor, 'auto'): | ||
| 205 | + default["color"] = titlecolor | ||
| 202 | 206 | if pad is None: | |
| 203 | 207 | pad = rcParams['axes.titlepad'] | |
| 204 | 208 | self._set_title_offset_trans(float(pad)) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1132,6 +1132,7 @@ def _validate_linestyle(ls): | |||
| 1132 | 1132 | # axes title | |
| 1133 | 1133 | 'axes.titlelocation': ['center', validate_axes_titlelocation], # alignment of axes title | |
| 1134 | 1134 | 'axes.titleweight': ['normal', validate_string], # font weight of axes title | |
| 1135 | + 'axes.titlecolor': ['auto', validate_color_or_auto], # font color of axes title | ||
| 1135 | 1136 | 'axes.titlepad': [6.0, validate_float], # pad from axes top to title in points | |
| 1136 | 1137 | 'axes.grid': [False, validate_bool], # display grid or not | |
| 1137 | 1138 | 'axes.grid.which': ['major', validate_axis_locator], # set whether the gid are by | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -179,6 +179,13 @@ def test_mec_rcparams(): | |||
| 179 | 179 | assert ln.get_markeredgecolor() == 'r' | |
| 180 | 180 | ||
| 181 | 181 | ||
| 182 | + def test_axes_titlecolor_rcparams(): | ||
| 183 | + mpl.rcParams['axes.titlecolor'] = 'r' | ||
| 184 | + _, ax = plt.subplots() | ||
| 185 | + title = ax.set_title("Title") | ||
| 186 | + assert title.get_color() == 'r' | ||
| 187 | + | ||
| 188 | + | ||
| 182 | 189 | def test_Issue_1713(tmpdir): | |
| 183 | 190 | rcpath = Path(tmpdir) / 'test_rcparams.rc' | |
| 184 | 191 | rcpath.write_text('timezone: UTC', encoding='UTF-32-BE') | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -358,6 +358,8 @@ | |||
| 358 | 358 | #axes.titlelocation : center ## alignment of the title: {left, right, center} | |
| 359 | 359 | #axes.titlesize : large ## fontsize of the axes title | |
| 360 | 360 | #axes.titleweight : normal ## font weight of title | |
| 361 | + #axes.titlecolor : auto ## color of the axes title, auto falls back to text.color | ||
| 362 | + ## as default value | ||
| 361 | 363 | #axes.titlepad : 6.0 ## pad between axes and title in points | |
| 362 | 364 | #axes.labelsize : medium ## fontsize of the x any y labels | |
| 363 | 365 | #axes.labelpad : 4.0 ## space between label and axis | |
| Back | FazBrowse Home | New Git URL |
0 commit comments