Skip to content

Add some kwarg normalization to plot()/fill(). #6345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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