8000 Allow both linestyle definition "accents" and dash-patterns as linestyle by lennart0901 · Pull Request #3772 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 12 commits into from
May 14, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add new documentation for set_linestyle of patches, collection and li…
…nes.
  • Loading branch information
lennart0901 committed Apr 14, 2015
commit 8d1f0e090013e1346bd412e7a4f45c7a3f8113a2
22 changes: 20 additions & 2 deletions lib/matplotlib/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,26 @@ def set_linestyle(self, ls):
"""
Set the linestyle(s) for the collection.

ACCEPTS: ['solid' | 'dashed', 'dashdot', 'dotted' |
(offset, on-off-dash-seq) ]
=========================== =================
Copy link
Member

Choose a reason for hiding this comment

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

@mdboom @efiring This breaks the doc-string scraping code for the tables in the docs. Should we revert the changes to put ACCEPTS : ... back in or re-work the doc-scraping?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
Expand Down
44 changes: 26 additions & 18 deletions lib/matplotlib/lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,33 +923,41 @@ def set_linewidth(self, w):

def set_linestyle(self, linestyle):
"""
Set the linestyle of the line (also accepts drawstyles)


================ =================
linestyle description
================ =================
``'-'`` solid
``'--'`` dashed
``'-.'`` dash_dot
``':'`` dotted
``'None'`` draw nothing
``' '`` draw nothing
``''`` draw nothing
================ =================
Set the linestyle of the line (also accepts drawstyles,
e.g., ``'steps--'``)


=========================== =================
linestyle description
=========================== =================
``'-'`` or ``'solid'`` solid line
``'--'`` or ``'dashed'`` dashed line
``'-.'`` or ``'dash_dot'`` dash-dotted line
``':'`` or ``'dotted'`` dotted line
``'None'`` draw nothing
``' '`` draw nothing
``''`` draw nothing
=========================== =================

'steps' is equivalent to 'steps-pre' and is maintained for
backward-compatibility.

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.

.. seealso::

:meth:`set_drawstyle`
To set the drawing style (stepping) of the plot.

ACCEPTS: [``'-'`` | ``'--'`` | ``'-.'`` | ``':'`` | ``'None'`` |
``' '`` | ``''``]

and any drawstyle in combination with a linestyle, e.g., ``'steps--'``.
Parameters
----------
ls : { '-', '--', '-.', ':'} and more see description
The line style.
"""
if not is_string_like(linestyle):
if len(linestyle) != 2:
Expand Down
21 changes: 20 additions & 1 deletion lib/matplotlib/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,26 @@ def set_linestyle(self, ls):
"""
Set the patch linestyle

ACCEPTS: ['solid' | 'dashed' | 'dashdot' | 'dotted']
=========================== =================
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.
"""
if ls is None:
ls = "solid"
Expand Down
0