Skip to content

Commit

Permalink
Merge pull request #4381 from tacaswell/legend_rcparams_doc_tests
Browse files Browse the repository at this point in the history
Legend rcparams doc tests
  • Loading branch information
efiring committed Apr 26, 2015
2 parents 7c7e614 + fb2f393 commit 5555f54
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 3 deletions.
14 changes: 11 additions & 3 deletions doc/users/whats_new/rcparams.rst
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
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

0 comments on commit 5555f54

Please sign in to comment.