Skip to content

Commit 478b181

Browse files
committed
Merge 'v1.4.x' into master
Conflicts: lib/matplotlib/__init__.py lib/matplotlib/tests/test_legend.py __init__: conflicts in white-listing tests on both branches test_legend: conflicts from adding new tests on both branches
2 parents e25f29c + e475489 commit 478b181

File tree

10 files changed

+41
-4
lines changed

10 files changed

+41
-4
lines changed

lib/matplotlib/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1395,7 +1395,6 @@ def tk_window_focus():
13951395
'matplotlib.tests.test_arrow_patches',
13961396
'matplotlib.tests.test_artist',
13971397
'matplotlib.tests.test_axes',
1398-
'matplotlib.tests.test_axes_grid1',
13991398
'matplotlib.tests.test_backend_bases',
14001399
'matplotlib.tests.test_backend_pdf',
14011400
'matplotlib.tests.test_backend_pgf',
@@ -1440,8 +1439,9 @@ def tk_window_focus():
14401439
'matplotlib.tests.test_tightlayout',
14411440
'matplotlib.tests.test_transforms',
14421441
'matplotlib.tests.test_triangulation',
1443-
'mpl_toolkits.tests.test_mplot3d',
14441442
'matplotlib.tests.test_widgets',
1443+
'mpl_toolkits.tests.test_mplot3d',
1444+
'mpl_toolkits.tests.test_axes_grid1',
14451445
]
14461446

14471447

lib/matplotlib/rcsetup.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,16 @@ def validate_float(s):
108108
raise ValueError('Could not convert "%s" to float' % s)
109109

110110

111+
def validate_float_or_None(s):
112+
"""convert s to float or raise"""
113+
if s is None:
114+
return None
115+
try:
116+
return float(s)
117+
except ValueError:
118+
raise ValueError('Could not convert "%s" to float' % s)
119+
120+
111121
def validate_int(s):
112122
"""convert s to int or raise"""
113123
try:
@@ -644,7 +654,7 @@ def __call__(self, s):
644654
# whether or not to draw a frame around legend
645655
'legend.frameon': [True, validate_bool],
646656
# alpha value of the legend frame
647-
'legend.framealpha': [1.0, validate_float],
657+
'legend.framealpha': [None, validate_float_or_None],
648658

649659
## the following dimensions are in fraction of the font size
650660
'legend.borderpad': [0.4, validate_float], # units are fontsize
Loading
Loading

lib/matplotlib/tests/test_legend.py

+27
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,33 @@ def test_labels_first():
7676
ax.legend(loc=0, markerfirst=False)
7777

7878

79+
@image_comparison(baseline_images=['rgba_alpha'],
80+
extensions=['png'], remove_text=True)
81+
def test_alpha_rgba():
82+
import matplotlib.pyplot as plt
83+
84+
fig, ax = plt.subplots(1, 1)
85+
ax.plot(range(10), lw=5)
86+
leg = plt.legend(['Longlabel that will go away'], loc=10)
87+
leg.legendPatch.set_facecolor([1, 0, 0, 0.5])
88+
89+
90+
@image_comparison(baseline_images=['rcparam_alpha'],
91+
extensions=['png'], remove_text=True)
92+
def test_alpha_rcparam():
93+
import matplotlib.pyplot as plt
94+
95+
fig, ax = plt.subplots(1, 1)
96+
ax.plot(range(10), lw=5)
97+
with mpl.rc_context(rc={'legend.framealpha': .75}):
98+
leg = plt.legend(['Longlabel that will go away'], loc=10)
99+
# this alpha is going to be over-ridden by the rcparam whith
100+
# sets the alpha of the patch to be non-None which causes the alpha
101+
# value of the face color to be discarded. This behavior may not be
102+
# ideal, but it is what it is and we should keep track of it changing
103+
leg.legendPatch.set_facecolor([1, 0, 0, 0.5])
104+
105+
79106
@image_comparison(baseline_images=['fancy'], remove_text=True)
80107
def test_fancy():
81108
# using subplot triggers some offsetbox functionality untested elsewhere

matplotlibrc.template

+1-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ backend : %(backend)s
321321
#legend.columnspacing : 2. # the border between the axes and legend edge in fraction of fontsize
322322
#legend.shadow : False
323323
#legend.frameon : True # whether or not to draw a frame around legend
324-
#legend.framealpha : 1.0 # opacity of of legend frame
324+
#legend.framealpha : None # opacity of of legend frame
325325
#legend.scatterpoints : 3 # number of scatter points
326326
#legend.facecolor : None # legend background color (when None inherits from axes.facecolor)
327327
#legend.edgecolor : None # legend edge color (when None inherits from axes.facecolor)

0 commit comments

Comments
 (0)