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

[MRG+1] Contour levels to colorbar. #3797

Merged
merged 4 commits into from Dec 7, 2016

Conversation

jaeilepp
Copy link
Contributor

Closes #3795

The colorbars are so small by default, that I had to make the tick labels a bit smaller.

@jaeilepp
Copy link
Contributor Author

colorbar

@jona-sassenhagen
Copy link
Contributor

Warning: it is possible, and often desirable, to set 0 contour levels. Wouldn't this then mean you have no units on the colorbar?

Otherwise, you're a beast!

@jaeilepp
Copy link
Contributor Author

Then it only shows the zero, but maybe this should also show vmax and vmin.

@jaeilepp
Copy link
Contributor Author

Ok. Tried it, and it looks a bit weird, since it's not evenly spaced.
colorbar

@jaeilepp
Copy link
Contributor Author

I'm not sure which is the best way to do this. Opinions?

@codecov-io
Copy link

codecov-io commented Nov 28, 2016

Current coverage is 86.38% (diff: 92.30%)

Merging #3797 into master will increase coverage by <.01%

@@             master      #3797   diff @@
==========================================
  Files           343        343          
  Lines         61271      61292    +21   
  Methods           0          0          
  Messages          0          0          
  Branches       9381       9384     +3   
==========================================
+ Hits          52929      52948    +19   
- Misses         5625       5626     +1   
- Partials       2717       2718     +1   

Sunburst

Powered by Codecov. Last update 07102b9...6833b0c

@jona-sassenhagen
Copy link
Contributor

Make it an alternative option IMO.

@jaeilepp
Copy link
Contributor Author

This made me realize that the contour levels aren't actually same for all the images.

@mmagnuski
Copy link
Member

I also think this shouldn't be the default. For multiple topomaps contour levels would have to be forced to be the same... BTW - how does it look like if you do it the other way: instead of forcing colorbar ticks to be where the contour lines are, force contour lines to be where colorbar ticks have been set?

@jaeilepp
Copy link
Contributor Author

Yeah, that's what I'm looking at now. Trying to find out how mpl does it. I don't want the contours to set to something like 166.6666666.

@mmagnuski
Copy link
Member

I don't remember ever seeing mpl setting ticks to such weird values. :) But you can access the tick locators in ticker module. I've never played with these classes though...

@jaeilepp
Copy link
Contributor Author

Now it's using the ticker levels and seems to work quite nicely. Here's how it looks with 3 contours.
contours

@jona-sassenhagen
Copy link
Contributor

jona-sassenhagen commented Nov 29, 2016

That looks quite good IMO!

A somewhat more far-fetched idea, could similar tech be used to threshold certain t score maps by significance levels eventually ..?

@jaeilepp
Copy link
Contributor Author

Probably. I don't know the stats package that well.

This changes the contour levels a little bit as can be seen from the pictures, but I suppose it's okay since the threshold levels were not previously visible anyway.

@mmagnuski
Copy link
Member

Looks good!

@jaeilepp jaeilepp changed the title Contour levels to colorbar. [MRG] Contour levels to colorbar. Nov 29, 2016
@agramfort
Copy link
Member

LGTM

if isinstance(contours, int):
from matplotlib import ticker
# nbins = ticks - 1, since 2 of the ticks are vmin and vmax, the
# correct number of bins equals to contours + 1.
Copy link
Contributor

Choose a reason for hiding this comment

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

"equals contours + 1" or "is equal to contours +1"

@agramfort
Copy link
Member

LGTM

can someone else have a look so @jaeilepp can have his +2?

@agramfort agramfort changed the title [MRG] Contour levels to colorbar. [MRG+1] Contour levels to colorbar. Dec 1, 2016
@jona-sassenhagen
Copy link
Contributor

jona-sassenhagen commented Dec 1, 2016 via email

@larsoner
Copy link
Member

larsoner commented Dec 1, 2016

Sorry to come late, but I actually think that showing the max/min and all the contour levels is cleanest. Even if it's not evenly spaced it's most informative in terms of what everything means in the plot

@jaeilepp
Copy link
Contributor Author

jaeilepp commented Dec 2, 2016

It also looks quite bad in most cases
values
values2
I would omit vmin and vmax.

@larsoner
Copy link
Member

larsoner commented Dec 2, 2016

Yeah that does look bad, and if it's fairly common that it happens then it's not worth it. I suspect it wouldn't be too difficult to come up with a heurestic for when to include hte vmin/vmax based on where the other contours are, but that can be another PR if someone gets bored.

LGTM, @jona-sassenhagen feel free to merge if you're happy

@jaeilepp
Copy link
Contributor Author

jaeilepp commented Dec 2, 2016

Yeah, I would have thought that there would have been an option for this in mpl's locator, but I couldn't find one that works.

@jona-sassenhagen
Copy link
Contributor

So we're still set on not having this as a parameter-accessible option? It's gonna become the new default?

@jaeilepp
Copy link
Contributor Author

jaeilepp commented Dec 6, 2016

I'm voting for this as a default. The other options would be more or less arbitrary values.

@mmagnuski
Copy link
Member

I think this should be accessible through a keyword arg... (contour_legend, contour_colorbar?)

@jona-sassenhagen
Copy link
Contributor

It's not easily user-changeable, isn't it? Which would mean it should be settable with a kwarg.

But I see your point @jaeilepp that the current method is arbitrary and maybe it's not so good to set "arbitrary" as a param.

@jaeilepp
Copy link
Contributor Author

jaeilepp commented Dec 6, 2016

Actually, plot_topomap now also accepts a list for contours. So maybe we can live without a new kwarg and just update the documentation.

@mmagnuski
Copy link
Member

I like the fact that contours are accepted. I was just a little afraid that if colorbar tick positioning is contour-dependent by default, then colorbar will easily get messy with many contour levels. I mean - it can be the default behavior, but it would be nice if it was possible to turn it off.

@agramfort
Copy link
Member

agramfort commented Dec 7, 2016 via email

@mmagnuski
Copy link
Member

My suggestion (and Jona's) was to add a keyword argument that allows to turn off this behavior, but make it default. @jaeilepp - would that be ok?

@larsoner
Copy link
Member

larsoner commented Dec 7, 2016

@mmagnuski can we add that once we hit a use case that needs it? Or do you already know there will be?

@mmagnuski
Copy link
Member

@Eric89GXL sure, I've played with it a bit now and I no longer think that colorbar will get messy for a reasonable number of contour levels. :)

@agramfort
Copy link
Member

agramfort commented Dec 7, 2016 via email

@jona-sassenhagen
Copy link
Contributor

Well it has my +1 :D

Tried it, looks good.

@mmagnuski
Copy link
Member

Yes, 👍 from me too :)

@larsoner larsoner merged commit eb4ccea into mne-tools:master Dec 7, 2016
@larsoner
Copy link
Member

larsoner commented Dec 7, 2016

Thanks @jaeilepp

@jona-sassenhagen
Copy link
Contributor

Thanks @jaeilepp !

@mmagnuski
Copy link
Member

Thanks @jaeilepp !!

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

6 participants