-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Allow both linestyle definition "accents" and dash-patterns as linestyle... #3265
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
Documentation to follow |
@@ -2074,7 +2074,7 @@ def unmasked_index_ranges(mask, compressed=True): | |||
(':', 'dotted')] | |||
|
|||
ls_mapper = dict(_linestyles) | |||
ls_mapper.update([(ls[1], ls[0]) for ls in _linestyles]) | |||
ls_mapperr = dict([(ls[1], ls[0]) for ls in _linestyles]) |
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.
Why do we have both ls_mapper
and ls_mapperr
?
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.
If you put the mapper into one, there is no way to decide which side of the mapping is "authoritative" (useable at the end in the backend). So I decided to divide them into a forward and reverse mapper here. So the mappers can be used without checking if the passed linestyle might be ok for the backend etc.
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.
can you use ls_mapper_r
which matches our convention for color maps?
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 was about to suggest that as well. Also, add a comment explaining the
reasoning you gave above.
On Tue, Jul 15, 2014 at 1:43 PM, Thomas A Caswell notifications@github.com
wrote:
In lib/matplotlib/cbook.py:
@@ -2074,7 +2074,7 @@ def unmasked_index_ranges(mask, compressed=True):
(':', 'dotted')]ls_mapper = dict(_linestyles)
-ls_mapper.update([(ls[1], ls[0]) for ls in _linestyles])
+ls_mapperr = dict([(ls[1], ls[0]) for ls in _linestyles])can you use ls_mapper_r which matches our convention for color maps?
—
Reply to this email directly or view it on GitHub
https://github.com/matplotlib/matplotlib/pull/3265/files#r14950740.
I'm trying to add the checks done in Collection.set_linestyle to Lines but the following lines causes problems
Do you have an idea why that does work in collections.py and not in lines.py Seems to be a cyclic import or something. |
are you getting (semi) circular imports? |
Ah yes, probably: |
Is there anything I can do about it, |
Hello, I added documentation and fixed the tests. P.S. Sorry for the silence, may Home-PC broke and I had to repair it... |
@@ -463,16 +463,16 @@ def set_linestyle(self, ls): | |||
""" | |||
Set the linestyle(s) for the collection. | |||
|
|||
ACCEPTS: ['solid' | 'dashed', 'dashdot', 'dotted' | | |||
ACCEPTS: [ '-' | '--' | '-.' | ':' | |
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.
This should be updated to use numpy doc
Parameters
----------
ls : { '-', '--', '-.', ':' , 'solid', 'dashed', 'dashdot', 'dotted', (offset, on-off-dash-seq)}
The line style. [[EXPLAIN on-off-dash-seq]]
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.
Note I updated the above comment.
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.
is it okay to have a linebreak here like
Parameters
----------
ls : { '-', '--', '-.', ':' , 'solid', 'dashed', 'dashdot', 'dotted',
(offset, on-off-dash-seq)}
The line style. [[EXPLAIN on-off-dash-seq]]
c2305c9
to
91ed617
Compare
I changed some things to your suggestions. |
Because this branch on longer merges cleanly into master. It needs to be re-based onto current master. |
…yle for collection, lines and patches. (code & tests)
Problem: cyclic import of backend_bases
changed collision detection in lines.py to use ``not linestyle``
… seperate image (to allow multiprocess testing...)
Needs more test cases. This obviously can't cover every case that fails.
PEP8 fails because of the long lines in docs for ls |
sigh, put a linebreak in it to make travis happy. @jenshnielsen Do you know if numpydoc can deal with multi-line enums for the type? |
Not really, When I fixed the doc problems I ended up putting a print statement into sphinx autodoc to be able to inspect the generated rst. I found that the tracebacks from sphinx usually pointed to the wrong places in the source. |
Added tests to test_fmt for _process_plot_format
multi-line type descriptions are not possible in numpydoc. It parses only the first line for the type. |
I tried to restrict the functionality of _process_plot_format to just parsing the format. I regard the two errors with "test_tri_smooth_" as bug, as calling triplot with a color fmt only throws the same error. |
Parameters | ||
---------- | ||
ls : { '-', '--', '-.', ':' , 'solid', 'dashed', 'dashdot', 'dotted', (offset, on-off-dash-seq)} | ||
The line style. [[EXPLAIN on-off-dash-seq]] |
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.
Can you explain the on-off-dash-seq input?
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.
Ah, I thought that might be one magic expanding thing.
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.
Does the type propagate into the keyword list of the class, that is printed at the very beginning of the class documentation?
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 think so? I would have to check to be sure.
and shortend type description to make travis happy
This is really strange 03b897f fails here but succeeds in my branch: |
The test that fails in 03b897f is using numpy 1.6 and python 2.6 that is likely different from what you are testing. |
@jenshnielsen: Please tell me how the test in my branch on my github repository lennart0901 and that one on matplotlib, that are done via travis and the same .travis.yml should differ? I'm not talking about the "test_line3d" tests that failed before. (Though I also did not do anything to fix them). I rather suspect there might be some race conditions when testing in parallel. The test that failed is in test_style.py and the error was that the temporary style file does not exist. I've no idea how my changes even touched that.
|
I have restarted the failing test. We will see what happens |
So what about that one now?? |
|
||
Parameters | ||
---------- | ||
ls : { '-', '--', '-.', ':'} and more see description |
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 would move most of this text to the main description of the docs? It comes down to how it renders when you build the documentation.
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.
?! What text do you mean, the parameter description, type or name? What main description of the docs, the one of Line2D? The tables of keyword arguments actually do not work correctly with numpydoc. Is that what you mean?
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.
Set linestyles(s) of collection
text about all the gory details
Parameters
---------------
ls : str
The linestyle
Sorry this feel like it is going very slowly, this is touching code used by a majority of the plots made with mpl and I want to make sure we get this right. |
# verbose.report('Unrecognized line style %s, %s' % | ||
# (linestyle, type(linestyle))) | ||
if linestyle in [' ', 'None', 'none', '']: | ||
linestyle = '' |
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.
This also seems like an API change to me, previously 'None'
was the canonical way to store 'don't draw anything' and now it is an empty string.
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.
Then I will make it 'None' and change the above to deal with it. In patches and collections there never was such a convention, what about these?
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'm just playing with the idea to just change get_linestyle to rewrite it, because having no linestyle compare to False
is kind of convenient. What do you think?
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.
That does make a tremendous about of sense to have the line style that means don't draw evaluate to false.
Historically we have had small API breaks on 1.X releases, particularly when they affect things that should not be part of the public API and do have protocol for deprecating APIs. My point is not that this is a show stopper, just that we need to be a thoughtful about it and make sure to document it.
Never mind, I also recognized that it is not just an isolated change. I could also try to factor out only the changes to make all plot-types accept all linestyles. e.g. changing the linestyle attribute from dict to list is not such a change.... |
There is another api change I consider important. get_linestyle returns the dash sequence if there is one and not the last linestyle. |
Sorry it was "--" before not the last linestyle |
I don't understand your last few comments about dashes. At some point we do need to go through do a cleaning of some of the core code, it just needs to be done with care. It is probably worth splitting this up into a couple of smaller PRs. For example the line fmt parsing + it's tests are probably stand alone. I am not sure I have a good enough grasp of the other changes, but believe you they can be pulled apart. attn @mdboom @efiring @pelson I am not super familiar with this code and don't know all of the reasons things are they way they are, one you you should weigh in here. |
@lennart0901 What do you want to do about this PR? |
As there is #3772. I think it is best to close this one. |
... for collection, lines and patches.
(code & tests)
see. #2136
This is a minimal patch. It seems to me that the linestyle handling could get some more cleanup.
e.g. in lines.py the drawing is handed over to some
_draw_xxx
methods, those are almost only stubs changing the name of the linestyle