Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Improve linestyles example#12586

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
timhoffm merged 9 commits intomatplotlib:masterfromthoo:linestyles
Oct 30, 2018
Merged

Conversation

thoo
Copy link
Contributor

PR Summary

Close#11908
To combine this two examples:line_styles_reference andlinestyles.
in order to reduce redundancy and also explain more about (offset, on-off-dash-seq).

What had done:

Removeline_styles_reference example and rewritelinestyles example.


# Reverse the list so that plots and linestyles are in same order.
linestyles = OrderedDict(linestyles[::-1])

plt.figure(figsize=(10, 6))
Copy link
Member

Choose a reason for hiding this comment

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

Not necessarily part of this PR, but since you're touching this code, would you be ok with putting it in OO format:

fig,ax=plt.subplots()

thoo reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

It is a good idea. I will update it with OO format.

*Note*: The dash style can also be configured via `.Line2D.set_dashes`
as shown in :doc:`/gallery/lines_bars_and_markers/line_demo_dash_control`
and passing a list of dash sequences using the keyword *dashes* to the
cycler in :doc:`property_cycle </tutorials/intermediate/color_cycle>`.
"""
import numpy as np
import matplotlib.pyplot as plt
from collections import OrderedDict
Copy link
Member

Choose a reason for hiding this comment

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

this can now be removed, since no longer an ordered dict.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I am still usinglinestyles = OrderedDict(linestyles[::-1]) here. I just reversed the list so that it follows the same order between the list description and the plot.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry about that then, but I don't think you need the ordered dict anyway?

@@ -3,31 +3,44 @@
Linestyles
==========

This examples showcases different linestyles copying those of Tikz/PGF.
This example showcases different linestyles copying those of Tikz/PGF.
Copy link
Member

Choose a reason for hiding this comment

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

Can this be linked to example of Tikz/PGF linestlyes? Otherwise, there's no context.

@@ -3,31 +3,44 @@
Linestyles
==========

This examples showcases different linestyles copying those of Tikz/PGF.
This example showcases different linestyles copying those of Tikz/PGF.
Linestyle can be provided as simple as *solid* , *dotted* or *dashed*.
Copy link
Member

Choose a reason for hiding this comment

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

Unclear whether this means I can use the wordsolid as an argument to Linestyle or this is talking about lines.

@story645
Copy link
Member

Thanks for the PR! I like the idea of combining the two examples, but maybe they should be left as standalone subplots so that there's a clean example of the symbol denoted way to do things versus the tuple way?

ImportanceOfBeingErnest and timhoffm reacted with thumbs up emoji

@QuLogicQuLogic changed the titleLinestylesImprove linestyles exampleOct 23, 2018
@thoo
Copy link
ContributorAuthor

thoo commentedOct 25, 2018
edited
Loading

@story645 Let me know if you want me to change anything. Thanks.

Linestyle can be provided as simple as *solid* , *dotted*, *dashed*
or *dashdot*. Moreover, the dashing of the line can be controlled by
a dash tuple such as (offset, (on_off_seq)) as mentioned in
`.Line2D.set_linestyle`. For e.g., ``(0, (3, 10, 1, 15))`` means
Copy link
Member

Choose a reason for hiding this comment

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

e.g. already means 'for example'; use 'For example' here.

('dotted', (0, (1, 5))),
('densely dotted', (0, (1, 1))),
linestyle_str = [
('solid', ('solid')), # Same as (0, ()) or '-'
Copy link
Member

Choose a reason for hiding this comment

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

The parentheses around the second element do nothing; are they necessary for something?

@thoo
Copy link
ContributorAuthor

@QuLogic Done. Thanks.

@jklymak
Copy link
Member

@thoo, this needs to pass CI obviously...

@thoo
Copy link
ContributorAuthor

@jklymak All tests are passed except Azure which I needazure-pipelines.yml'.

timhoffm
timhoffm previously requested changesOct 28, 2018


plt.figure(figsize=(10, 6))
ax = plt.subplot(1, 1, 1)
def simple_plot(ax, linestyles):
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
defsimple_plot(ax,linestyles):
defplot_linestyles(ax,linestyles):

ax.annotate(str(linestyle), xy=(0.0, i), xycoords=reference_transform,
xytext=(-6, -12), textcoords='offset points', color="blue",
fontsize=8, ha="right", family="monospace")
fig, ax = plt.subplots(2, 1, gridspec_kw={'height_ratios': [1, 2]},
Copy link
Member

Choose a reason for hiding this comment

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

Either usefig, axs = orfig, (ax1, ax2) =.ax is canonically used for a single Axes only.

('dashdotdotted', (0, (3, 5, 1, 5, 1, 5))),
('densely dashdotdotted', (0, (3, 1, 1, 1, 1, 1)))])
('loosely dashdotdotted', (0, (3, 10, 1, 10, 1, 10))),
Copy link
Member

Choose a reason for hiding this comment

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

I would keep the order loosely, normal, densely.

for i, (name, linestyle) in enumerate(linestyles):
ax.annotate(repr(linestyle), xy=(0.0, i), xycoords=reference_transform,
xytext=(-6, -12), textcoords='offset points', color="blue",
fontsize=8, ha="right", family="monospace")

X, Y = np.linspace(0, 100, 10), np.zeros(10)
Copy link
Member

@timhoffmtimhoffmOct 28, 2018
edited
Loading

Choose a reason for hiding this comment

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

Move X, Y into the plot function.

@@ -3,50 +3,65 @@
Linestyles
==========

This examples showcases different linestyles copying those of Tikz/PGF.
Linestyle can be provided as simple as *solid* , *dotted*, *dashed*
Copy link
Member

@timhoffmtimhoffmOct 28, 2018
edited
Loading

Choose a reason for hiding this comment

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

Simple linestyles can be defined using the strings "solid", "dotted", "dashed"or "dashdot". More refined control can be achieved by providing a dash tuple``(offset, (on_off_seq))``. For example, ``(0, (3, 10, 1, 15))`` means(3pt line, 10pt space, 1pt line, 15pt space) with no offset. See also`.Line2D.set_linestyle`.

Copy link
Member

@QuLogicQuLogicOct 28, 2018
edited by timhoffm
Loading

Choose a reason for hiding this comment

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

If you are going to change this line, please remove the dashes between 'pt' and 'line'/'space'; they are not technically required.

@QuLogic thanks. Incorporated in the proposal above.

Copy link
Member

@timhoffmtimhoffm left a comment

Choose a reason for hiding this comment

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

Anyone can merge after CI pass.

@timhoffmtimhoffm merged commit9fa3e60 intomatplotlib:masterOct 30, 2018
@QuLogicQuLogic added this to thev3.1 milestoneOct 30, 2018
thoo added a commit to thoo/matplotlib that referenced this pull requestNov 3, 2018
* 'master' ofhttps://github.com/matplotlib/matplotlib: (50 commits)  Set up CI with Azure Pipelines (matplotlib#12617)  Added comment for test.  Correctly remove nans when drawing paths with pycairo.  Improve docs on Axes limits and direction  Extend sphinx Makefile to cleanup completely  Remove explicit figure number  Update contributing.rst  Update contributing.rst  DOC: Add badge and link to making PR tutorial  Added test cases for scatter plot: 1) empty data/color, 2) pandas.Series with non-0 starting index.  TST: mark test_constrainedlayout.py::test_colorbar_location as flaky (matplotlib#12683)  Remove deprecation warnings in tests (matplotlib#12686)  Make ticks in demo_axes_rgb.py visible  Change ipython block to code-block  Improve linestyles example (matplotlib#12586)  document-textpath  Fix index out of bound error for testing first element of iterable.  TST: test that get_ticks works  FIX: fix error in colorbar.get_ticks not having valid data  Replaced warnings.warn with either logging.warnings or cbook._warn_external  ...
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@QuLogicQuLogicQuLogic left review comments

@story645story645story645 approved these changes

@timhoffmtimhoffmtimhoffm approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.1.0
Development

Successfully merging this pull request may close these issues.

5 participants
@thoo@story645@jklymak@QuLogic@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp