Skip to content
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

Make edgecolors and facecolors the same when using stepfilled histogram. #6494

Merged
merged 1 commit into from May 30, 2016

Conversation

Carreau
Copy link
Contributor

@Carreau Carreau commented May 28, 2016

Closes #6493

for x, y, c in reversed(list(zip(xvals, yvals, color))):
split = 2 * len(bins)
split = 2 * len(bins)
for x, y, c in reversed(list(zip(xvals, yvals, reversed(color)))):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove the list()? It's unnecessary.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it isn't. reversed() requires a sequence; zip in py3 returns an iterator.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you're right. That's interesting; I guess it makes sense since zip doesn't supply __len__, but it's odd that something like dict.keys() won't work with it either.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's because py3 went wild over iterators, so dict.keys() and similar methods all return iterators. There is no __getitem__, so no way to reverse the order.

@QuLogic QuLogic added this to the 2.0 (style change major release) milestone May 28, 2016
@Carreau
Copy link
Contributor Author

Carreau commented May 29, 2016

Hum, my patch also change the order of colors for when filled=False so that's breaking change right ?

@Carreau Carreau force-pushed the stepfilled branch 2 times, most recently from 2238775 to a01aad3 Compare May 29, 2016 00:36
@efiring
Copy link
Member

efiring commented May 29, 2016

Yes, I think so, unless it fixed previously broken behavior. The logic of your patch is not obvious to me--but given the horrendous expanse of code in which it is embedded, that's not surprising. Does stepfilled even need both edgecolors and facecolors? If they are always going to be the same, I don't see any point having edgecolors--they can be 'none'.

@Carreau Carreau force-pushed the stepfilled branch 3 times, most recently from 081f5fe to e927259 Compare May 29, 2016 05:00
@Carreau
Copy link
Contributor Author

Carreau commented May 29, 2016

Does stepfilled even need both edgecolors and facecolors?

I believe with the edges the overall size of the bad will be bigger, I doubt it make much difference with default values, but with linewidth != defaultvalue, it will likely. It make some artifacts:

screen shot 2016-05-28 at 22 04 09

Which are less visible but still there with edges shown.

screen shot 2016-05-28 at 22 04 54

@Carreau
Copy link
Contributor Author

Carreau commented May 29, 2016

I think I got it, using classic style:

Master:
1k qdoxrx581x21yizz fqhtoo1lc751algqtrcuit20klviwhtpf9sjq2zba8l4denxevqgghhbduy nv sqeeeiiitydtfyfeeiiiyrbkimreeiiiyrwczjxfuiiiyqqbkemrkiiiyqqwi3ixfuiiyqqqrgfmbgkiyqqqgi3ibnxiyqqqgjhfmtikoqqqggh3ijmxiuqqgghhfuqiasqqgghhhalmnevqgghhbbu4f8bvgbgpifj9loa

This patch:

teygaaaaasuvork5cyii

@Carreau Carreau force-pushed the stepfilled branch 2 times, most recently from b161807 to c65e0ab Compare May 29, 2016 17:34
@Carreau
Copy link
Contributor Author

Carreau commented May 29, 2016

Test failures seem to be :

  1. the comparison with the reference image generated locally, any tip on that ?
  2. unrelated in test_backend_pdf , grayscale_alpha. not sure what to do.

@tacaswell
Copy link
Member

export MPLLOCALFREETYPE=1 before running the tests which will install the version of freetype we pinned our tests to.

the grayscale_alpha has been flaky recently, not sure why.

patches.append(self.fill(
x[:split], y[:split],
closed=True if fill else None,
facecolor=c,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just use color = c in both cases?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The black outlines on stepfilled seem odd to me, is that the behavior in 1.5.1 as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because otherwise histype=stepfilled would have colored edges instead of black ones:

filled=None != filled=False

screen shot 2016-05-29 at 13 59 13

But, I thought so too in the beginning.

(Compare above screenshot with test file in the PR)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect this behavior is going to change in 2.x as I think edge color now defaults to face color rather than 'k' so just leave this as-is.

@Carreau
Copy link
Contributor Author

Carreau commented May 29, 2016

the grayscale_alpha has been flaky recently, not sure why.

This one is happy now.

export MPLLOCALFREETYPE=1 before running the tests which will install the version of freetype we pinned our tests to.

I went for ImageComparisonTest.remove_text(fig) when generating the base figure, Travis is happy now.

@Carreau
Copy link
Contributor Author

Carreau commented May 29, 2016

The black outlines on stepfilled seem odd to me, is that the behavior in 1.5.1 as well?

Let me retry, but I believe so.

fig, axes = plt.subplots(nrows=2, ncols=4)
axes = axes.flatten()


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra blank line.


for kg,_type,ax in zip(kwargs, types, axes):
ax.hist(x, n_bins, histtype=_type, stacked=True,**kg)
ax.set_title('%s/%s' % (kg, _type) )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space before ).

@Carreau
Copy link
Contributor Author

Carreau commented May 29, 2016

Here is the test figure generated by 1.5.x - v1.5.2rc2-4-g7605dd4

mpl15

Easy to spot, the color are wrong on the first ax.

histype='stepfilled' always have black edges
histype='step' always have colored edges.

kwarg fill=True force to fill colors,
kwarg fill=False|None force to not filling.
not passing the kwarg, fills when using 'stepfilled', but not when using 'step'.

I agree that this is confusing, but that's how it behaves.

I'm not against a change, (especially if it simplify things) but it's not my decision to make.

ax.set_title('%s/%s' % (kg, _type) )
ax.set_ylim(ymin=-50)

patches= axes[0].patches
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space before =.

@QuLogic
Copy link
Member

QuLogic commented May 29, 2016

Sorry, I had to add a bunch of PEP8 comments because pep8 is not running on this file for whatever reason.

@Carreau
Copy link
Contributor Author

Carreau commented May 29, 2016

Sorry, I had to add a bunch of PEP8 comments because pep8 is not running on this file for whatever reason.

"a foolish consistency is the hobgoblin of little minds" says pep-8 :-) I've enabled it in my editor and fixed (a few) extra you missed. The file seem to be crippled with more pep8 issues (96 apparently) but I doubt it's the right time to fix'em'all.

@Carreau
Copy link
Contributor Author

Carreau commented May 29, 2016

I'm not against a change, (especially if it simplify things) but it's not my decision to make.

If you decide to change, I would gladly deprecate stepfilled for step, and point user toward passing fill=True, and/or, edgecolor='k' which allow to get the same result.

@tacaswell
Copy link
Member

I think better to leave it as is for now, deprecating stepfill in favor of step is not something I think we would want to do on 2.0 either way.

All of hist is a mess and should be replaced...

@tacaswell
Copy link
Member

@Carreau Thanks!

@Carreau
Copy link
Contributor Author

Carreau commented May 30, 2016

Thanks to you ! Happy 2.0b release !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants