Skip to content

Commit

Permalink
Merge pull request matplotlib#6345 from WeatherGod/use_normalization
Browse files Browse the repository at this point in the history
Add some kwarg normalization to plot()/fill().
  • Loading branch information
efiring committed May 4, 2016
2 parents e1499e1 + 8e0963d commit ed0b475
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
19 changes: 14 additions & 5 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@

rcParams = matplotlib.rcParams

_alias_map = {'color': ['c'],
'linewidth': ['lw'],
'linestyle': ['ls'],
'facecolor': ['fc'],
'edgecolor': ['ec'],
'markerfacecolor': ['mfc'],
'markeredgecolor': ['mec'],
'markeredgewidth': ['mew'],
'markersize': ['ms'],
}


def _plot_args_replacer(args, data):
if len(args) == 1:
Expand Down Expand Up @@ -1415,11 +1426,7 @@ def plot(self, *args, **kwargs):
self.cla()
lines = []

# Convert "c" alias to "color" immediately, to avoid
# confusion farther on.
c = kwargs.pop('c', None)
if c is not None:
kwargs['color'] = c
kwargs = cbook.normalize_kwargs(kwargs, _alias_map)

for line in self._get_lines(*args, **kwargs):
self.add_line(line)
Expand Down Expand Up @@ -4537,6 +4544,8 @@ def fill(self, *args, **kwargs):
if not self._hold:
self.cla()

kwargs = cbook.normalize_kwargs(kwargs, _alias_map)

patches = []
for poly in self._get_patches_for_fill(*args, **kwargs):
self.add_patch(poly)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions lib/matplotlib/tests/test_cycles.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,30 @@ def test_fillcycle_ignore():
ax.legend(loc='upper left')


@image_comparison(baseline_images=['property_collision_plot'],
remove_text=True, extensions=['png'])
def test_property_collision_plot():
fig, ax = plt.subplots()
ax.set_prop_cycle('linewidth', [2, 4])
for c in range(1, 4):
ax.plot(np.arange(10), c * np.arange(10), lw=0.1)
ax.plot(np.arange(10), 4 * np.arange(10))
ax.plot(np.arange(10), 5 * np.arange(10))


@image_comparison(baseline_images=['property_collision_fill'],
remove_text=True, extensions=['png'])
def test_property_collision_fill():
fig, ax = plt.subplots()
xs = np.arange(10)
ys = 0.25 * xs**.5 + 2
ax.set_prop_cycle(linewidth=[2, 3, 4, 5, 6], facecolor='bgcmy')
for c in range(1, 4):
ax.fill(xs, c * ys, lw=0.1)
ax.fill(xs, 4 * ys)
ax.fill(xs, 5 * ys)


@cleanup
def test_valid_input_forms():
fig, ax = plt.subplots()
Expand Down

0 comments on commit ed0b475

Please sign in to comment.