Closed
Labels
Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Milestone
Description
This no longer works:
import matplotlib.pyplot as plt
from cycler import cycler
plt.rc('axes', prop_cycle=(
cycler('dashes', [(None, None), (None, None), (6, 6), (3, 3), (1.5, 1.5)])))but it used to work in 1.5.
Now it yields
TypeError: float() argument must be a string or a number, not 'NoneType'
Metadata
Metadata
Assignees
Labels
Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Activity
amueller commentedon Feb 24, 2017
I would appreciate a work-around, too. The intention is that the first two lines are solid, and then we get dashes.
amueller commentedon Feb 24, 2017
Using a small positive number is a decent workaround for me for now:
In case anyone wonders wtf I'm doing here: In b/w, I feel like we can distinguish two solid lines by color, but for more than two lines I want dash-patterns.
afvincent commentedon Feb 24, 2017
An alternative workaround may be to use the
plotkwarglinestyle(orls) instead of thedashesone. One can then use named line styles ('solid' or '-' for example), or (offset, on-off ink sequence). It is a bit more verbose but the following script seems to be working properly on masterPS : @amueller is it normal that there are 6 lines on your picture while
plt.plotis only called 5 times in your example script?amueller commentedon Feb 24, 2017
I changed the script but then didn't reupload the picture ;)
amueller commentedon Feb 24, 2017
Thanks for your suggestion. That seems cleaner.
afvincent commentedon Feb 24, 2017
The issue still has to be fixed but at least this workaround should avoid using
(1, 0.01)dashes when the meaning is "a solid line please" ;).dkua commentedon Mar 2, 2017
Was just looking through the Issues page for fun and decided to try my hand at fixing this.
Ran the code from the OP using different versions of
1.5.xand2.0.xand this is definitely only a bug that exists in2.0.x. So I ran the code throughpdband found that it was failing on line 316 invalidate_nseq_float()ofrcsetup.py. A quick looks through the1.5.xcodebase shows thatvalidate_nseq_float()exists there so it's not the original cause of this bug.Some more diving with
pdband I found thatvalidate_nseq_float()was being called on thecycler()input in OP on line 861 ofrcsetup.pyinvalidate_cycler(). This line was calling the_prop_validatorsdictionary using "dashes" as the key and the list of five tuples as the vals which came from the OP code. The "dashes" entry in the_prop_validatorsdict corresponds to thevalidate_dashlistcallable on line 698 which is a listified version ofvalidate_nseq_float(). Looking through the1.5.xcode again it seems that this extra cycle "dashlist" validation code doesn't exist there so it seems to be the reason that the OP code is failing. Checkinggit blameon line 698 I find that this extra validation code comes from commit 9ee5f8d which landed in2.0.x.validate_nseq_float(s)checks that the given finite sequencescontains only floats but looking at the documentation for dashes,(None, None)is valid input so using a float-only validator is a regression. Then the solution to this bug seems to be either:validate_nseq_floatto allow Nones which I have done in dkua@353acebvalidate_nseq_float_or_Nonein dkua@72120b3 and dkua@7916b3aI've tested both of those options manually on my computer using the OP code and they both produce a correct looking plot without crashing as in
1.5.x. I can add in a quick test and submit one of the options as a PR for this issue but have not decided which option is better and want to ask the matplotlib team first. The first option seems suboptimal sincevalidate_nseq_float()is used elsewhere in the code but the second option adds in extra near-duplicate code. Either option it seems the int equivalent of these validators should also be changed since this might come up for them later on too (maybe?).Please let me know what y'all think.
Fixes matplotlib#8141
kenmaca commentedon Mar 5, 2017
I've submitted a PR that should fix this issue by allowing
Nonevalues only when validating dashed line styles viavalidate_nseq_floatwith a newallow_noneflag flipped on, while retaining the original behaviour for other validators usingvalidate_nseq_floatto avoid any breaking changes.Adding another validator just for dashed lines seems redundant, IMO.
Fixes matplotlib#8141
Merge pull request #8196 from kenmaca/pr-dash-verification-8141
Fixes matplotlib#8141
Merge pull request #1 from kenmaca/pr-dash-verification-8141
update (#7)
Merge pull request matplotlib#8196 from kenmaca/pr-dash-verification-…