-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Feature stack base #1671
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
Feature stack base #1671
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
24f537f
[ENH] added baseline feature to stacked graph.
Tillsten b21b348
pep8 compliance
Tillsten 6f7a769
Fix typos
dmcdougall 6975bcb
Add stackplot baseline demo
dmcdougall ff8cce4
Update changelog and whats_new
dmcdougall 6dc5887
Add stackplot baseline test
dmcdougall f318d39
Remove text from regression test output
dmcdougall 339ca4e
Vectorise the loops
dmcdougall 6b4678b
Add docstring to example funtion
dmcdougall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
|
||
np.random.seed(0) | ||
def layers(n, m): | ||
""" | ||
Return *n* random Gaussian mixtures, each of length *m*. | ||
""" | ||
def bump(a): | ||
x = 1 / (.1 + np.random.random()) | ||
y = 2 * np.random.random() - .5 | ||
z = 10 / (.1 + np.random.random()) | ||
for i in range(m): | ||
w = (i / float(m) - y) * z | ||
a[i] += x * np.exp(-w * w) | ||
a = np.zeros((m, n)) | ||
for i in range(n): | ||
for j in range(5): | ||
bump(a[:, i]) | ||
return a | ||
|
||
d = layers(3, 100) | ||
|
||
plt.subplots() | ||
plt.stackplot(range(100), d.T, baseline='wiggle') | ||
plt.show() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+31.5 KB
lib/matplotlib/tests/baseline_images/test_axes/stackplot_test_baseline.pdf
Binary file not shown.
Binary file added
BIN
+50.8 KB
lib/matplotlib/tests/baseline_images/test_axes/stackplot_test_baseline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 know its only an example, but a docstring would be nice here - something which focuses on the purpose of the function, rather than its args/kwargs.
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.
Actually, this is not uncommon to do in the examples. IIRC, the sphinx
doc-builder will take the docstring portion of the example, and render it
as ReST text above the source code portion. If one feels like having a
docstring there, feel free. The more the better.
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.
Sure 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.
Explanation of the code:
This is just a direct copy of the original code. All it does is calculating random Gaussians.
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.
Done in bd204e1.