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

Update example Step Demo#13148

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
jklymak merged 1 commit intomatplotlib:masterfromtimhoffm:example-step
Jan 10, 2019
Merged
Show file tree
Hide file tree
Changes fromall commits
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
1 change: 1 addition & 0 deletions.flake8
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -146,6 +146,7 @@ per-file-ignores =
examples/lines_bars_and_markers/joinstyle.py: E402
examples/lines_bars_and_markers/scatter_piecharts.py: E402
examples/lines_bars_and_markers/span_regions.py: E402
examples/lines_bars_and_markers/step_demo.py: E402
examples/misc/agg_buffer.py: E402
examples/misc/anchored_artists.py: E501
examples/misc/contour_manual.py: E501
Expand Down
46 changes: 29 additions & 17 deletionsexamples/lines_bars_and_markers/step_demo.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,30 +3,42 @@
Step Demo
=========

Example step plots.
This example demonstrates the use of `.pyplot.step` for piece-wise constant
curves. In particular, it illustrates the effect of the parameter *where*
on the step position.

The circular markers created with `.pyplot.plot` show the actual data
positions so that it's easier to see the effect of *where*.

"""
import numpy as np
from numpy import ma
import matplotlib.pyplot as plt

x = np.arange(1, 7, 0.4)
y0 = np.sin(x)
y = y0.copy() + 2.5
x = np.arange(14)
y = np.sin(x / 2)

plt.step(x, y, label='pre (default)')
plt.step(x, y + 2, label='pre (default)')
plt.plot(x, y + 2, 'C0o', alpha=0.5)

y -= 0.5
plt.step(x, y, where='mid',label='mid')
plt.step(x, y + 1, where='mid', label='mid')
plt.plot(x, y + 1, 'C1o',alpha=0.5)

y -= 0.5
plt.step(x, y, where='post', label='post')
plt.plot(x, y, 'C2o', alpha=0.5)

y = ma.masked_where((y0 > -0.15) & (y0 < 0.15), y - 0.5)
plt.step(x, y, label='masked (pre)')

plt.legend()

plt.xlim(0, 7)
plt.ylim(-0.5, 4)

plt.legend(title='Parameter where:')
plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions, methods, classes and modules is shown
# in this example:

import matplotlib
matplotlib.axes.Axes.step
matplotlib.pyplot.step

[8]ページ先頭

©2009-2025 Movatter.jp