Repository navigation
[MRG] use mpl default color cycle - #5186
Conversation
|
Hm ... the default color cycle is horrid for MPL < 2.0 (or 1.5, I forgot). Maybe we can detect the MPL version, and set it to the MPL color cycle if it's recent, and set it to the corresponding HTML colors if it's not (and when the old versions of MPL are no longer supported, the latter code is dropped)? Or is that too involved for what used to be a simple list of hex vals? |
|
@sappelhoff can you show how examples look like now? |
I would rather just copy the HTML codes directly and use them always. |
|
given the current errors, I think copying in the new mpl default hex codes is the way to go ... regarding showing how the examples look like ... I did the following:
... unfortunately, that has been running for 30 minutes now and seems to be stuck at: I thought this would build the docs new (locally) with my changed code, so that I could then simply view the resulting files in my browser and make a screenshot. Am I doing this the wrong way? |
|
There is a line you can add to your commit message that will mean you get the entire CircleCI rebuild. I can't find it though - @larsoner ? |
|
If you want to do specific examples locally use |
|
As I mentioned in the related issue, you need to do something special to replace |
|
I tried to find some handy tool that picks the most "red" color out of a list of hex codes ... but I didn't find something nice and short ... so I just picked by hand and started replacing the 'r' code with that hexcode. What about these lines ... is this referring to white and blue? If so, the blue should perhaps be replaced as well with the MPL hexcolor. |
|
No those are actual keypress codes not colors :) |
This could go in the same place as the CYCLE and be named e.g. |
Codecov Report
@@ Coverage Diff @@
## master #5186 +/- ##
==========================================
- Coverage 88.28% 88.27% -0.02%
==========================================
Files 358 358
Lines 66221 66298 +77
Branches 11251 11253 +2
==========================================
+ Hits 58461 58522 +61
- Misses 4951 4965 +14
- Partials 2809 2811 +2 |
|
Something like: BAD_COLOR = u'#d62728'
COLORS = [u'#1f77b4', u'#ff7f0e', u'#2ca02c', BAD_COLOR, u'#9467bd',
u'#8c564b', u'#e377c2', u'#7f7f7f', u'#bcbd22', u'#17becf']and then replace those conditional 'r' lines to BAD_COLOR? |
|
Yeah that's what I had in mind, let's see if the CIs agree |
|
@sappelhoff can you take a few minutes to try this and see if it works as it does on Also paste a screenshot of how it looks now that the color has changed? |
|
Looks red enough to me |
|
Okay, and the CIs are happy. How do we make use of the [circle full] now? Wasn't that so we could see how the examples look like with the new colors? |
|
Click on the CircleCI "Details", log in to CircleCI via GitHub, click the Artifacts tab, browse the site for examples that use the color cycle. I'm assuming these are a few: These are all from |
|
Thanks @larsoner, but then I'd probably have to set up circle CI for my fork, right? I think that's too much trouble for now. To me, the colors look fine, neither exciting nor ugly. |
|
No you don't need to set it up separately, they have already built for this
PR. The login step is just to get access to the artifacts theday already
exist
… |
| '#CD7F32', '#FF4040', '#ADFF2F', '#8E2323', '#FF1493'] | ||
| BAD_COLOR = u'#d62728' | ||
| COLORS = [u'#1f77b4', u'#ff7f0e', u'#2ca02c', BAD_COLOR, u'#9467bd', | ||
| u'#8c564b', u'#e377c2', u'#7f7f7f', u'#bcbd22', u'#17becf'] |
There was a problem hiding this comment.
I would not do it like this. If we now use mpl defaults we should use its rcParams. If someone want to change the MNE colors it would be able to do it via setting the global mpl default values.
There was a problem hiding this comment.
but how would you identify a "bad color" out of the rcParams? Especially, if these colors could change anytime via the global mpl default vals?
There was a problem hiding this comment.
- Use whatever is in
rcParamsat the time of plotting (so we'll need a private_get_color_cyclefunction or so that we call whenever we start a plotting function that wants a color cycle) - For annotations (this logic can also be in
_get_color_cycle(..., annotations=False)):- If
'r'is in the list, use it as bad color when plotting annotations - If not, add it and use it
- If
|
We're gonna drive @sappelhoff crazy :) |
|
I like @larsoner 's suggestion.
the annotations plot can stick to the current behavior using such an
auxiliary function.
we can explain this by saying that it needs colors with certain semantics.
|
|
And |
|
I like C3 better than r
As far as the fishiness, knowing the code where it's used I think we'll be
okay
… |
|
What I mean is, if both C3 and r show up on the same plot, they will be easily confused. |
|
True but hopefully a quite rare corner case (and one we could document)
… |
|
@sappelhoff wanna finish this? |
|
(BTW also please use |
| fname_out : str | ||
| The filename used for storing the diff. Could be useful for | ||
| when a temporary file is used. | ||
|
|
There was a problem hiding this comment.
to comply with pydocstyle pep257 ... it's cosmetic and should be avoided, I know ... I tried to limit it
There was a problem hiding this comment.
I don't see it in that spec. One of their example even does not have it:
def complex(real=0.0, imag=0.0):
"""Form a complex number.
Keyword arguments:
real -- the real part (default 0.0)
imag -- the imaginary part (default 0.0)
"""
if imag == 0.0 and real == 0.0:
return complex_zero
...
Does make docstyle complain for you? It's what we use for checking docstyle
There was a problem hiding this comment.
yes, it does not seem to be in the spec. I used pydocstyle. Apparently pep257 doesn't say anything about this ...
There was a problem hiding this comment.
Yes we use pydocstyle in our CIs but we have specific includes/excludes that we follow. Doing make docstyle in the mne-python root does the tests that we follow.
There was a problem hiding this comment.
wouldn't it be better to accept only "one style", either with a blank line before the end of the docstring or without it? Right now it's very mixed across the codebase.
There was a problem hiding this comment.
Yes at some point. Right now I think we have predominantly followed having no newline.
|
Travis seems unrelated. Here's an example on how the new colors look: https://8929-1301584-gh.circle-artifacts.com/0/html/auto_examples/inverse/plot_custom_inverse_solver.html |
|
@sappelhoff travis is not happy is this MRG? can you point to the rendered examples affected by this? |
true, but I don't really know what to do with this error:
it seems unrelated
I didn't build the other examples to use CircleCI sparingly, as sensibly advised by @larsoner |
|
@sappelhoff I restarted the travis failure. one trick is to make a cosmit in the affected examples so they get rendered by circle |
@agramfort: yes, I selected the example where the changes of this PR would be most apparent, and then made some cosmetic changes there. That's the example I linked to above. Travis is happy again :-) |
| if color is None: | ||
| if dark_background: | ||
| color = ['w'] + COLORS | ||
| color = ['w'] + _get_color_list() |
There was a problem hiding this comment.
did you check the plot_evoked_topo with dark_background ?
|
@agramfort see below for several screenshots of Dark background (
|
|
mmmh I don't really see why the coverage is reduced ... apart from that, I think this is ready to be merged. |
larsoner
left a comment
There was a problem hiding this comment.
Other than needing to revert the newlines +1 for merge
| ------- | ||
| stc : instance of SourceEstimate | ||
| The source estimates. | ||
|
|
| fname_out : str | ||
| The filename used for storing the diff. Could be useful for | ||
| when a temporary file is used. | ||
|
|
larsoner
left a comment
There was a problem hiding this comment.
Other than two minor things LGTM
|
|
||
| - Prepare transition to Python 3. This release will be the last release compatible with Python 2. The next version will be Python 3 only. | ||
|
|
||
| - func:`mne.viz.plot_evoked_topo` and other functions requiring a color cycle will now default to Matplotlib rcParams colors through :func:`mne.viz.utils._get_color_list`: by `Stefan Appelhoff`_ |
There was a problem hiding this comment.
only things in python_reference.rst will link properly with :func:, also we don't usually talk about private functions in whats_new.rst. So instead of having the private functions mentioned it's better to simply omit the "through" part or say something like "... and other functions requiring a color cycle have been refactored to ..." or
|
|
||
| def __init__(self, ax, collection, ch_names, | ||
| alpha_other=0.3): # noqa: D102 | ||
| alpha_other=0.3): # noqa: D107 |
There was a problem hiding this comment.
D107 is in our global ignore list so no need to add it:
|
@larsoner and @jona-sassenhagen ok for you? if so good to go from my end. thx @sappelhoff |
|
I love it! Circle:
|
|
CircleCI has been flakey lately |
|
Thanks @sappelhoff |






fixes #5154