-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Allow both linestyle definition "accents" and dash-patterns as linestyle #3772
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
Changes from all commits
31b7b91
14fe5db
8d1f0e0
a18bad9
3fc7a0b
9108a4b
0ec4e67
e6718ca
a09d4ad
8b90be7
7858040
937248d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Split `matplotlib.cbook.ls_mapper` in two | ||
````````````````````````````````````````` | ||
|
||
The `matplotlib.cbook.ls_mapper` dictionary is split into two now to | ||
distinguish between qualified linestyle used by backends and | ||
unqualified ones. `ls_mapper` now maps from the short symbols | ||
(e.g. `"--"`) to qualified names (`"solid"`). The new ls_mapper_r is | ||
the reversed mapping. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Mostly unified linestyles for Lines, Patches and Collections | ||
```````````````````````````````````````````````````````````` | ||
|
||
The handling of linestyles for Lines, Patches and Collections has been | ||
unified. Now they all support defining linestyles with short symbols, | ||
like `"--"`, as well as with full names, like `"dashed"`. Also the | ||
definition using a dash pattern (`(0., [3., 3.])`) is supported for all | ||
methods using Lines, Patches or Collections. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -482,27 +482,43 @@ def set_linestyle(self, ls): | |
""" | ||
Set the linestyle(s) for the collection. | ||
|
||
ACCEPTS: ['solid' | 'dashed', 'dashdot', 'dotted' | | ||
(offset, on-off-dash-seq) ] | ||
=========================== ================= | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a PR to demonstrate docscraping using numpydoc: #3859 |
||
linestyle description | ||
=========================== ================= | ||
``'-'`` or ``'solid'`` solid line | ||
``'--'`` or ``'dashed'`` dashed line | ||
``'-.'`` or ``'dash_dot'`` dash-dotted line | ||
``':'`` or ``'dotted'`` dotted line | ||
=========================== ================= | ||
|
||
Alternatively a dash tuple of the following form can be provided:: | ||
|
||
(offset, onoffseq), | ||
|
||
where ``onoffseq`` is an even length tuple of on and off ink | ||
in points. | ||
|
||
Parameters | ||
---------- | ||
ls : { '-', '--', '-.', ':'} and more see description | ||
The line style. | ||
""" | ||
try: | ||
dashd = backend_bases.GraphicsContextBase.dashd | ||
if cbook.is_string_like(ls): | ||
ls = cbook.ls_mapper.get(ls, ls) | ||
if ls in dashd: | ||
dashes = [dashd[ls]] | ||
elif ls in cbook.ls_mapper: | ||
dashes = [dashd[cbook.ls_mapper[ls]]] | ||
else: | ||
raise ValueError() | ||
elif cbook.iterable(ls): | ||
try: | ||
dashes = [] | ||
for x in ls: | ||
if cbook.is_string_like(x): | ||
x = cbook.ls_mapper.get(x, x) | ||
if x in dashd: | ||
dashes.append(dashd[x]) | ||
elif x in cbook.ls_mapper: | ||
dashes.append(dashd[cbook.ls_mapper[x]]) | ||
else: | ||
raise ValueError() | ||
elif cbook.iterable(x) and len(x) == 2: | ||
|
@@ -511,7 +527,7 @@ def set_linestyle(self, ls): | |
raise ValueError() | ||
except ValueError: | ||
if len(ls) == 2: | ||
dashes = ls | ||
dashes = [ls] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not understand this change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well dashes always contains a list of dash patterns, one for each part of the collection. A dash patterns is a 2-tuple, so if you pass in a 2-tuple it is converted into a list of one 2-tuple. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did this used to be broken or was this handled someplace else? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It used to be broken and throw a SystemError. I added a test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, great! |
||
else: | ||
raise ValueError() | ||
else: | ||
|
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 may be neurotic, but should this be documented in api_changes.rst?
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.
You are the maintainer. :)
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 there some order in the file?
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.
It should be more-or-less by date. Can you actually throw it into this folder (https://github.com/matplotlib/matplotlib/tree/master/doc/api/api_changes)? This is an attempt to alleviate the merge conflicts in the docs.
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.
Argh, to late I just added a note at the end of the Changes 1.4.x
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.
It definitely should not go there as I don't think this is going to be back-ported to the 1.4 series.
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.
Fixed that.