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
Violin Plots #2996
Merged
Merged
Violin Plots #2996
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
d9f71fb
Added functionality for plotting the actual violin bodies to violinplot.
solvents da40c9d
Added ksdensity (KDE) function in mlab and adapted _axes violinplot f…
khchan b9d7e03
Added statistics lines to the violinplot function.
solvents 3c4c619
Added horizontal violin plot feature compatible with means, extremas …
e6f1b38
Fixed bug for regression test #1181 in scipy unit tests; ksdensity is…
khchan e8b3041
Reverted 69b304c.
solvents 91a33e8
Re-added points parameter to violinplot.
solvents 690c770
Merging for pep8 compliance for mlab's GaussianKDE
khchan b98b591
Added violinplot tests.
LTS42 2fa212a
updated version of test_axes.py with violinplot tests
DonaldSeo 14e6402
Finished violin plot tests with horizontal feature
LTS42 8761ed4
Initial tests for ksdensity
ef89a14
re worked the tests in test_mlab to work with the modified GaussianKDE
grdlok 0555ef1
Fixed some style issues. Added violinplot to boilerplate.py
solvents 6277624
Added silverman and scott tests.
kelsiegr 39c66a9
implementations of the evaluate tests
grdlok ca7d605
Fixed kde for invalid bw_methods, misc test formatting.
khchan 11aee86
Renamed vp_coverage baseline images, added bw_method paramater to vio…
khchan f189325
Updated kde tests in test_mlab.py to reflect changes to imports in te…
solvents ad0bcd4
Fixed an issue in violinplot where the top end of violins would be tr…
solvents b8db6d2
Refactored axes.violinplot into cbook.violin_stats (arranges violin p…
solvents 01c3176
Updated violinplot. Removed pdf and svg test images.
solvents File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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 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 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 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,48 @@ | ||
""" | ||
Demo of the new violinplot functionality | ||
""" | ||
|
||
import random | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
|
||
# fake data | ||
fs = 10 # fontsize | ||
pos = [1,2,4,5,7,8] | ||
data = [np.random.normal(size=100) for i in pos] | ||
|
||
fig, axes = plt.subplots(nrows=2, ncols=3, figsize=(6,6)) | ||
|
||
axes[0, 0].violinplot(data, pos, points=20, widths=0.1, | ||
showmeans=True, showextrema=True, showmedians=True) | ||
axes[0, 0].set_title('Custom violinplot 1', fontsize=fs) | ||
|
||
axes[0, 1].violinplot(data, pos, points=40, widths=0.3, | ||
showmeans=True, showextrema=True, showmedians=True, | ||
bw_method='silverman') | ||
axes[0, 1].set_title('Custom violinplot 2', fontsize=fs) | ||
|
||
axes[0, 2].violinplot(data, pos, points=60, widths=0.5, showmeans=True, | ||
showextrema=True, showmedians=True, bw_method=0.5) | ||
axes[0, 2].set_title('Custom violinplot 3', fontsize=fs) | ||
|
||
axes[1, 0].violinplot(data, pos, points=80, vert=False, widths=0.7, | ||
showmeans=True, showextrema=True, showmedians=True) | ||
axes[1, 0].set_title('Custom violinplot 4', fontsize=fs) | ||
|
||
axes[1, 1].violinplot(data, pos, points=100, vert=False, widths=0.9, | ||
showmeans=True, showextrema=True, showmedians=True, | ||
bw_method='silverman') | ||
axes[1, 1].set_title('Custom violinplot 5', fontsize=fs) | ||
|
||
axes[1, 2].violinplot(data, pos, points=200, vert=False, widths=1.1, | ||
showmeans=True, showextrema=True, showmedians=True, | ||
bw_method=0.5) | ||
axes[1, 2].set_title('Custom violinplot 6', fontsize=fs) | ||
|
||
for ax in axes.flatten(): | ||
ax.set_yticklabels([]) | ||
|
||
fig.suptitle("Violin Plotting Examples") | ||
fig.subplots_adjust(hspace=0.4) | ||
plt.show() |
This file contains 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
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.
Generally there is an attempt to remove as much of the implementation from Axes, and implement either a set of functions, or a class to hold the resulting artists in its own sub-module (e.g.
matplotlib.violin
). The axes methods then simply become interfacing functions to construct an appropriate structure and subsequently return it.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.
Should that be included in this PR? If so, should at accompany a change in boxplots as well? I'm alright with working on this some more, but it could be a while to get it done.
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.
My inclination is to leave this for now (so we can get this merged and tag the RC 'soon'), but I will leave that call to @pelson