MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_legend_linewidth

Function test_legend_linewidth

lib/matplotlib/tests/test_legend.py:1681–1709  ·  view source on GitHub ↗

Test legend.linewidth parameter and rcParam.

()

Source from the content-addressed store, hash-verified

1679
1680
1681def test_legend_linewidth():
1682 """Test legend.linewidth parameter and rcParam."""
1683 fig, ax = plt.subplots()
1684 ax.plot([1, 2, 3], label='data')
1685
1686 # Test direct parameter
1687 leg = ax.legend(linewidth=2.5)
1688 assert leg.legendPatch.get_linewidth() == 2.5
1689
1690 # Test rcParam
1691 with mpl.rc_context({'legend.linewidth': 3.0}):
1692 fig, ax = plt.subplots()
1693 ax.plot([1, 2, 3], label='data')
1694 leg = ax.legend()
1695 assert leg.legendPatch.get_linewidth() == 3.0
1696
1697 # Test None default (should inherit from patch.linewidth)
1698 with mpl.rc_context({'legend.linewidth': None, 'patch.linewidth': 1.5}):
1699 fig, ax = plt.subplots()
1700 ax.plot([1, 2, 3], label='data')
1701 leg = ax.legend()
1702 assert leg.legendPatch.get_linewidth() == 1.5
1703
1704 # Test that direct parameter overrides rcParam
1705 with mpl.rc_context({'legend.linewidth': 1.0}):
1706 fig, ax = plt.subplots()
1707 ax.plot([1, 2, 3], label='data')
1708 leg = ax.legend(linewidth=4.0)
1709 assert leg.legendPatch.get_linewidth() == 4.0
1710
1711
1712def test_patchcollection_legend():

Callers

nothing calls this directly

Calls 4

subplotsMethod · 0.45
plotMethod · 0.45
legendMethod · 0.45
get_linewidthMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…