Skip to content

Legend rcparams doc tests #4381

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

Merged
merged 3 commits into from
Apr 26, 2015
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
14 changes: 11 additions & 3 deletions doc/users/whats_new/rcparams.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,17 @@ but not yet implemented.

Added "figure.titlesize" and "figure.titleweight" keys to rcParams
``````````````````````````````````````````````````````````````````
Two new keys were added to rcParams to control the default font size and weight
used by the figure title (as emitted by ``pyplot.suptitle()``).

Two new keys were added to rcParams to control the default font size
and weight used by the figure title (as emitted by
``pyplot.suptitle()``).

Added ``legend.facecolor`` and ``legend.edgecolor`` keys to rcParams
```````````````````````````````````````````````````````````````````

The new keys control colors (background and edge) of legend patches.
The value ``'inherit'`` for these rcParams falls uses the value of
``axes.facecolor`` and ``axes.edgecolor``.


``image.composite_image`` added to rcParams
Expand All @@ -28,4 +37,3 @@ Added "toolmanager" to "toolbar" possible values
````````````````````````````````````````````````

The new value enables the use of ``ToolManager``

46 changes: 46 additions & 0 deletions lib/matplotlib/tests/test_rcparams.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
import warnings

import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.tests import assert_str_equal
from matplotlib.testing.decorators import cleanup, knownfailureif
import matplotlib.colors as mcolors
from nose.tools import assert_true, assert_raises, assert_equal
from nose.plugins.skip import SkipTest
import nose
Expand Down Expand Up @@ -180,6 +182,50 @@ def test_Bug_2543_newer_python():
with mpl.rc_context():
mpl.rcParams['svg.fonttype'] = True


@cleanup
def _legend_rcparam_helper(param_dict, target, get_func):
with mpl.rc_context(param_dict):
_, ax = plt.subplots()
ax.plot(range(3), label='test')
leg = ax.legend()
assert_equal(getattr(leg.legendPatch, get_func)(), target)


def test_legend_facecolor():
get_func = 'get_facecolor'
rcparam = 'legend.facecolor'
test_values = [({rcparam: 'r'},
mcolors.colorConverter.to_rgba('r')),
({rcparam: 'inherit',
'axes.facecolor': 'r'
},
mcolors.colorConverter.to_rgba('r')),
({rcparam: 'g',
'axes.facecolor': 'r'},
mcolors.colorConverter.to_rgba('g'))
]
for rc_dict, target in test_values:
yield _legend_rcparam_helper, rc_dict, target, get_func


def test_legend_edgecolor():
get_func = 'get_edgecolor'
rcparam = 'legend.edgecolor'
test_values = [({rcparam: 'r'},
mcolors.colorConverter.to_rgba('r')),
({rcparam: 'inherit',
'axes.edgecolor': 'r'
},
mcolors.colorConverter.to_rgba('r')),
({rcparam: 'g',
'axes.facecolor': 'r'},
mcolors.colorConverter.to_rgba('g'))
]
for rc_dict, target in test_values:
yield _legend_rcparam_helper, rc_dict, target, get_func


def test_Issue_1713():
utf32_be = os.path.join(os.path.dirname(__file__),
'test_utf32_be_rcparams.rc')
Expand Down