-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Conversation
Just pushed up the fix to the pep8 error. Everything else passes, though. We probably should make sure all of the aliases I made make sense. It might even make sense to have a single location with this information so that it can be used as a default, and also used by the prop_cycle validator. |
Buried someplace in |
Yes, and that mechanism should be burned with fire.
|
I am 👍 on merging this as-is and worrying about cleaning up the repeated content / centralizing the location of the alias mappings later. I think that this is something that traitlets may provide a reasonable programatic access to. |
@WeatherGod Are you happy with the |
Eh, like I said, it might make more sense to break it out into parts But those concerns aren't about the API itself. I do think the precedence On Sun, May 1, 2016 at 9:59 PM, Thomas A Caswell notifications@github.com
|
The tests are at https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/tests/test_cbook.py#L347 I do not thing that the |
@@ -4537,6 +4544,19 @@ def fill(self, *args, **kwargs): | |||
if not self._hold: | |||
self.cla() | |||
|
|||
kwargs = cbook.normalize_kwargs(kwargs, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest factoring out this dictionary so it is not repeated.
I moved the alias map dictionary up to a module-level private dictionary. |
This passes now. |
I am still 👍 on this. It makes things better (but obviously not perfect and applied everywhere). Leave to @efiring to merge. |
@tacaswell Should I go ahead and merge v1.5.x into v2.x, and v2.x into master now, or do you want to do that sweep now or later? Do you expect those merges to be completely straightforward? |
If you want to do it go ahead. We should have a better policy of when to do that. I think there is a conflict between 2.x and master at the moment. |
On 2016/05/04 8:51 AM, Thomas A Caswell wrote:
I did both merges and pushed; I didn't see any problems or unexpected |
Failure on 2.x! It generates quite a different test image. Here is the expected image, from 1.5.x: |
The color change is expected. If the property cycle does not contain color it falls back to black. |
But why did the order of the line widths change? |
off the top of my head, my guess is that the cycler was getting advanced internally, but its values not used until the last two lines. Makes me think the fallback handling to black is not correct? |
The test code is below. If the cycler is supposed to advance with each call to I think the thing to do is to change the expected plot for v2.x and master, and not worry about why the behavior is different in 1.5.x, since we hope we don't have to release that, and this is a corner case with a new feature anyway. But is this correct? Is the explicit 'lw' overriding the 'linewidth' because it is explicit, or because short form overrides long form, or is it potentially random? Do we need more tests and illustrations of how the combination of the cycler and alias handling are supposed to work? @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)) |
No, the first three calls to ax.plot() should not advance the cycler. I doubt this has anything to do with alias handling. Rather, the logic in prop_cycler is such that it only advances the property cycler if it has properties that weren't specified by the user. I think the recent fallback handling code broke this implicit assumption by inserting a color property into the property cycle (sort of, I think -- I haven't looked closely). |
The way the fall back is implemented is to mulitply any cycler with out |
I have a fix for this on #6374 I can pick it apart add do the last 2 commits as thier own PR, I was just being lazy and trying to avoid have to do a re-base. |
A first stab at normalizing kwargs in these two core plotting functions. Closes #6343 and possibly others.