Skip to content

Commit 98a2e64

Browse files
committed
Merge remote-tracking branch 'matplotlib/v2.x'
Conflicts: lib/matplotlib/axes/_base.py - whitespace conflicts lib/matplotlib/rcsetup.py - kept 2.x version
2 parents a260058 + ccb1072 commit 98a2e64

File tree

10 files changed

+69
-67
lines changed

10 files changed

+69
-67
lines changed

lib/matplotlib/__init__.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ def matplotlib_fname():
866866
_deprecated_ignore_map = {
867867
}
868868

869-
_obsolete_set = set(['tk.pythoninspect', ])
869+
_obsolete_set = set(['tk.pythoninspect', 'legend.isaxes'])
870870
_all_deprecated = set(chain(_deprecated_ignore_map,
871871
_deprecated_map, _obsolete_set))
872872

@@ -885,6 +885,8 @@ class RcParams(dict):
885885
if key not in _all_deprecated)
886886
msg_depr = "%s is deprecated and replaced with %s; please use the latter."
887887
msg_depr_ignore = "%s is deprecated and ignored. Use %s"
888+
msg_obsolete = ("%s is obsolete. Please remove it from your matplotlibrc "
889+
"and/or style files.")
888890

889891
# validate values on the way in
890892
def __init__(self, *args, **kwargs):
@@ -902,6 +904,9 @@ def __setitem__(self, key, val):
902904
alt = _deprecated_ignore_map[key]
903905
warnings.warn(self.msg_depr_ignore % (key, alt))
904906
return
907+
elif key in _obsolete_set:
908+
warnings.warn(self.msg_obsolete % (key,))
909+
return
905910
try:
906911
cval = self.validate[key](val)
907912
except ValueError as ve:
@@ -923,6 +928,10 @@ def __getitem__(self, key):
923928
warnings.warn(self.msg_depr_ignore % (key, alt))
924929
key = alt
925930

931+
elif key in _obsolete_set:
932+
warnings.warn(self.msg_obsolete % (key,))
933+
return None
934+
926935
val = dict.__getitem__(self, key)
927936
if inverse_alt is not None:
928937
return inverse_alt(val)

lib/matplotlib/axes/_base.py

+6-10
Original file line numberDiff line numberDiff line change
@@ -164,16 +164,9 @@ def __setstate__(self, state):
164164
def set_prop_cycle(self, *args, **kwargs):
165165
if not (args or kwargs) or (len(args) == 1 and args[0] is None):
166166
prop_cycler = rcParams['axes.prop_cycle']
167-
if prop_cycler is None and 'axes.color_cycle' in rcParams:
168-
clist = rcParams['axes.color_cycle']
169-
prop_cycler = cycler('color', clist)
170167
else:
171168
prop_cycler = cycler(*args, **kwargs)
172169

173-
# Make sure the cycler always has at least one color
174-
if 'color' not in prop_cycler.keys:
175-
prop_cycler = prop_cycler * cycler('color', ['k'])
176-
177170
self.prop_cycler = itertools.cycle(prop_cycler)
178171
# This should make a copy
179172
self._prop_keys = prop_cycler.keys
@@ -203,6 +196,8 @@ def get_next_color(self):
203196
"""
204197
Return the next color in the cycle.
205198
"""
199+
if 'color' not in self._prop_keys:
200+
return 'k'
206201
return six.next(self.prop_cycler)['color']
207202

208203
def set_lineprops(self, line, **kwargs):
@@ -1044,11 +1039,12 @@ def cla(self):
10441039
axis=rcParams['axes.grid.axis'])
10451040
props = font_manager.FontProperties(
10461041
size=rcParams['axes.titlesize'],
1047-
weight=rcParams['axes.titleweight']
1048-
)
1042+
weight=rcParams['axes.titleweight'])
10491043

1044+
title_offset_points = rcParams['axes.titlepad']
10501045
self.titleOffsetTrans = mtransforms.ScaledTranslation(
1051-
0.0, 5.0 / 72.0, self.figure.dpi_scale_trans)
1046+
0.0, title_offset_points / 72.0,
1047+
self.figure.dpi_scale_trans)
10521048
self.title = mtext.Text(
10531049
x=0.5, y=1.0, text='',
10541050
fontproperties=props,

lib/matplotlib/colors.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,8 @@ def to_rgba(c, alpha=None):
126126
# Special-case nth color syntax because it should not be cached.
127127
if _is_nth_color(c):
128128
from matplotlib import rcParams
129-
from matplotlib.rcsetup import cycler
130129
prop_cycler = rcParams['axes.prop_cycle']
131-
if prop_cycler is None and 'axes.color_cycle' in rcParams:
132-
clist = rcParams['axes.color_cycle']
133-
prop_cycler = cycler('color', clist)
134-
colors = prop_cycler._transpose().get('color', 'k')
130+
colors = prop_cycler.by_key().get('color', ['k'])
135131
c = colors[int(c[1]) % len(colors)]
136132
try:
137133
rgba = _colors_full_map.cache[c, alpha]

lib/matplotlib/mpl-data/stylelib/classic.mplstyle

+2-2
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ axes.grid : False # display grid or not
179179
axes.grid.which : major
180180
axes.grid.axis : both
181181
axes.titlesize : large # fontsize of the axes title
182+
axes.titlepad : 5.0 # pad between axes and title in points
182183
axes.titleweight : normal # font weight for axes title
183184
axes.labelsize : medium # fontsize of the x any y labels
184185
axes.labelpad : 5.0 # space between label and axis
@@ -267,7 +268,6 @@ grid.alpha : 1.0 # transparency, between 0.0 and 1.0
267268
legend.fancybox : False # if True, use a rounded box for the
268269
# legend, else a rectangle
269270
legend.loc : upper right
270-
legend.isaxes : True # this option is internally ignored
271271
legend.numpoints : 2 # the number of points in the legend line
272272
legend.fontsize : large
273273
legend.borderpad : 0.4 # border whitespace in fontsize units
@@ -503,4 +503,4 @@ animation.convert_path: convert # Path to ImageMagick's convert binary.
503503
animation.convert_args:
504504
animation.html: none
505505

506-
_internal.classic_mode: True
506+
_internal.classic_mode: True

lib/matplotlib/rcsetup.py

+14-17
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,7 @@ def validate_animation_writer_path(p):
10511051
'axes.titlesize': ['large', validate_fontsize], # fontsize of the
10521052
# axes title
10531053
'axes.titleweight': ['normal', six.text_type], # font weight of axes title
1054+
'axes.titlepad': [9.0, validate_float], # pad from axes top to title in points
10541055
'axes.grid': [False, validate_bool], # display grid or not
10551056
'axes.grid.which': ['major', validate_axis_locator], # set wether the gid are by
10561057
# default draw on 'major'
@@ -1117,23 +1118,19 @@ def validate_animation_writer_path(p):
11171118

11181119
#legend properties
11191120
'legend.fancybox': [True, validate_bool],
1120-
1121-
# at some point, legend.loc should be changed to 'best'
11221121
'legend.loc': ['best', validate_legend_loc],
1123-
1124-
# this option is internally ignored - it never served any useful purpose
1125-
'legend.isaxes': [True, validate_bool],
1126-
11271122
# the number of points in the legend line
11281123
'legend.numpoints': [1, validate_int],
11291124
# the number of points in the legend line for scatter
1130-
'legend.scatterpoints': [3, validate_int],
1131-
'legend.fontsize': ['large', validate_fontsize],
1132-
1133-
# whether or not to draw a frame around legend
1125+
'legend.scatterpoints': [1, validate_int],
1126+
'legend.fontsize': ['medium', validate_fontsize],
1127+
# the relative size of legend markers vs. original
1128+
'legend.markerscale': [1.0, validate_float],
1129+
'legend.shadow': [False, validate_bool],
1130+
# whether or not to draw a frame around legend
11341131
'legend.frameon': [True, validate_bool],
1135-
# alpha value of the legend frame
1136-
'legend.framealpha': [None, validate_float_or_None],
1132+
# alpha value of the legend frame
1133+
'legend.framealpha': [0.8, validate_float_or_None],
11371134

11381135
## the following dimensions are in fraction of the font size
11391136
'legend.borderpad': [0.4, validate_float], # units are fontsize
@@ -1153,7 +1150,7 @@ def validate_animation_writer_path(p):
11531150
'legend.markerscale': [1.0, validate_float],
11541151
'legend.shadow': [False, validate_bool],
11551152
'legend.facecolor': ['inherit', validate_color_or_inherit],
1156-
'legend.edgecolor': ['k', validate_color_or_inherit],
1153+
'legend.edgecolor': ['none', validate_color_or_inherit],
11571154

11581155
# tick properties
11591156
'xtick.top': [True, validate_bool], # draw ticks on the top side
@@ -1206,13 +1203,13 @@ def validate_animation_writer_path(p):
12061203
'figure.autolayout': [False, validate_bool],
12071204
'figure.max_open_warning': [20, validate_int],
12081205

1209-
'figure.subplot.left': [0.125, ValidateInterval(0, 1, closedmin=True,
1206+
'figure.subplot.left': [0.155, ValidateInterval(0, 1, closedmin=True,
12101207
closedmax=True)],
1211-
'figure.subplot.right': [0.9, ValidateInterval(0, 1, closedmin=True,
1208+
'figure.subplot.right': [0.87, ValidateInterval(0, 1, closedmin=True,
12121209
closedmax=True)],
1213-
'figure.subplot.bottom': [0.1, ValidateInterval(0, 1, closedmin=True,
1210+
'figure.subplot.bottom': [0.13, ValidateInterval(0, 1, closedmin=True,
12141211
closedmax=True)],
1215-
'figure.subplot.top': [0.9, ValidateInterval(0, 1, closedmin=True,
1212+
'figure.subplot.top': [0.87, ValidateInterval(0, 1, closedmin=True,
12161213
closedmax=True)],
12171214
'figure.subplot.wspace': [0.2, ValidateInterval(0, 1, closedmin=True,
12181215
closedmax=False)],

lib/matplotlib/testing/decorators.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ def check_freetype_version(ver):
176176

177177
return found >= ver[0] and found <= ver[1]
178178

179+
179180
class ImageComparisonTest(CleanupTest):
180181
@classmethod
181182
def setup_class(cls):
@@ -213,7 +214,8 @@ def remove_text(figure):
213214

214215
def test(self):
215216
baseline_dir, result_dir = _image_directories(self._func)
216-
217+
if self._style != 'classic':
218+
raise KnownFailureTest('temporarily disabled until 2.0 tag')
217219
for fignum, baseline in zip(plt.get_fignums(), self._baseline_images):
218220
for extension in self._extensions:
219221
will_fail = not extension in comparable_formats()

lib/matplotlib/tests/test_backend_pgf.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from matplotlib.testing.compare import compare_images, ImageComparisonFailure
1818
from matplotlib.testing.decorators import (_image_directories, switch_backend,
1919
cleanup)
20-
20+
from matplotlib.testing.noseclasses import KnownFailureTest
2121

2222
baseline_dir, result_dir = _image_directories(lambda: 'dummy func')
2323

@@ -43,6 +43,8 @@ def check_for(texsystem):
4343

4444

4545
def compare_figure(fname, savefig_kwargs={}, tol=0):
46+
# TODO remove this before tagging 2.0
47+
raise KnownFailureTest('temporarily disabled until 2.0 tag')
4648
actual = os.path.join(result_dir, fname)
4749
plt.savefig(actual, **savefig_kwargs)
4850

lib/matplotlib/tests/test_cycles.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ def test_linestylecycle_basic():
7070
ax.set_prop_cycle(cycler('ls', ['-', '--', ':']))
7171
xs = np.arange(10)
7272
ys = 0.25 * xs + 2
73-
ax.plot(xs, ys, label='solid', lw=4)
73+
ax.plot(xs, ys, label='solid', lw=4, color='k')
7474
ys = 0.45 * xs + 3
75-
ax.plot(xs, ys, label='dashed', lw=4)
75+
ax.plot(xs, ys, label='dashed', lw=4, color='k')
7676
ys = 0.65 * xs + 4
77-
ax.plot(xs, ys, label='dotted', lw=4)
77+
ax.plot(xs, ys, label='dotted', lw=4, color='k')
7878
ys = 0.85 * xs + 5
79-
ax.plot(xs, ys, label='solid2', lw=4)
79+
ax.plot(xs, ys, label='solid2', lw=4, color='k')
8080
ax.legend(loc='upper left')
8181

8282

@@ -131,8 +131,8 @@ def test_property_collision_plot():
131131
ax.set_prop_cycle('linewidth', [2, 4])
132132
for c in range(1, 4):
133133
ax.plot(np.arange(10), c * np.arange(10), lw=0.1, color='k')
134-
ax.plot(np.arange(10), 4 * np.arange(10))
135-
ax.plot(np.arange(10), 5 * np.arange(10))
134+
ax.plot(np.arange(10), 4 * np.arange(10), color='k')
135+
ax.plot(np.arange(10), 5 * np.arange(10), color='k')
136136

137137

138138
@image_comparison(baseline_images=['property_collision_fill'],

matplotlibrc.template

+24-24
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ backend : $TEMPLATE_BACKEND
297297
#axes.linewidth : 1.0 # edge linewidth
298298
#axes.grid : False # display grid or not
299299
#axes.titlesize : large # fontsize of the axes title
300+
#axes.titlepad : 9.0 # pad between axes and title in points
300301
#axes.labelsize : medium # fontsize of the x any y labels
301302
#axes.labelpad : 5.0 # space between label and axis
302303
#axes.labelweight : normal # weight of the x and y labels
@@ -388,33 +389,32 @@ backend : $TEMPLATE_BACKEND
388389

389390

390391
### GRIDS
391-
#grid.color : b0b0b0 # grid color
392+
#grid.color : b0b0b0 # grid color
392393
#grid.linestyle : - # solid
393394
#grid.linewidth : 1.0 # in points
394395
#grid.alpha : 1.0 # transparency, between 0.0 and 1.0
395396

396397
### Legend
397-
#legend.fancybox : True # if True, use a rounded box for the
398-
# legend, else a rectangle
399398
#legend.loc : best
400-
#legend.isaxes : True
401-
#legend.numpoints : 1 # the number of points in the legend line
402-
#legend.fontsize : large
403-
#legend.borderpad : 0.5 # border whitespace in fontsize units
404-
#legend.markerscale : 1.0 # the relative size of legend markers vs. original
405-
# the following dimensions are in axes coords
406-
#legend.labelspacing : 0.5 # the vertical space between the legend entries in fraction of fontsize
407-
#legend.handlelength : 2. # the length of the legend lines in fraction of fontsize
408-
#legend.handleheight : 0.7 # the height of the legend handle in fraction of fontsize
409-
#legend.handletextpad : 0.8 # the space between the legend line and legend text in fraction of fontsize
410-
#legend.borderaxespad : 0.5 # the border between the axes and legend edge in fraction of fontsize
411-
#legend.columnspacing : 2. # the border between the axes and legend edge in fraction of fontsize
399+
#legend.frameon : True # whether or not to draw a frame around legend
400+
#legend.framealpha : 0.8 # legend frame transparency
401+
#legend.facecolor : inherit # inherit from axes.facecolor; or color spec
402+
#legend.edgecolor : none
403+
#legend.fancybox : True # if True, use a rounded box for the
404+
# legend, else a rectangle
412405
#legend.shadow : False
413-
#legend.frameon : True # whether or not to draw a frame around legend
414-
#legend.framealpha : None # opacity of of legend frame
415-
#legend.scatterpoints : 3 # number of scatter points
416-
#legend.facecolor : inherit
417-
#legend.edgecolor : k
406+
#legend.numpoints : 1 # the number of marker points in the legend line
407+
#legend.scatterpoints : 1 # number of scatter points
408+
#legend.markerscale : 1.0 # the relative size of legend markers vs. original
409+
#legend.fontsize : medium
410+
# Dimensions as fraction of fontsize:
411+
#legend.borderpad : 0.4 # border whitespace
412+
#legend.labelspacing : 0.5 # the vertical space between the legend entries
413+
#legend.handlelength : 2.0 # the length of the legend lines
414+
#legend.handleheight : 0.7 # the height of the legend handle
415+
#legend.handletextpad : 0.8 # the space between the legend line and legend text
416+
#legend.borderaxespad : 0.5 # the border between the axes and legend edge
417+
#legend.columnspacing : 2.0 # column separation
418418

419419
### FIGURE
420420
# See http://matplotlib.org/api/figure_api.html#matplotlib.figure.Figure
@@ -432,10 +432,10 @@ backend : $TEMPLATE_BACKEND
432432

433433
# The figure subplot parameters. All dimensions are a fraction of the
434434
# figure width or height
435-
#figure.subplot.left : 0.125 # the left side of the subplots of the figure
436-
#figure.subplot.right : 0.9 # the right side of the subplots of the figure
437-
#figure.subplot.bottom : 0.1 # the bottom of the subplots of the figure
438-
#figure.subplot.top : 0.9 # the top of the subplots of the figure
435+
#figure.subplot.left : 0.155 # the left side of the subplots of the figure
436+
#figure.subplot.right : 0.87 # the right side of the subplots of the figure
437+
#figure.subplot.bottom : 0.13 # the bottom of the subplots of the figure
438+
#figure.subplot.top : 0.87 # the top of the subplots of the figure
439439
#figure.subplot.wspace : 0.2 # the amount of width reserved for blank space between subplots
440440
#figure.subplot.hspace : 0.2 # the amount of height reserved for white space between subplots
441441

0 commit comments

Comments
 (0)