Last active
June 4, 2016 09:08
-
-
Save nerevar/7ef3a840844d22ba2be5 to your computer and use it in GitHub Desktop.
python neat boxplot #python #matplotlib #boxplot #graph
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
import matplotlib.pyplot as plt | |
def draw(data): | |
bp = plt.boxplot(data, | |
widths=0.7, | |
notch=True, # adds median notch | |
patch_artist=True, | |
) | |
plt.grid(axis='y', # set y-axis grid lines | |
linestyle='--', # use dashed lines | |
which='major', # only major ticks | |
color='lightgrey', # line colour | |
alpha=0.7) # make lines semi-translucent | |
plt.setp(bp['whiskers'], color='DarkMagenta', linewidth=1.5) | |
plt.setp(bp['caps'], color='DarkMagenta', linewidth=1.5) | |
plt.setp(bp['boxes'], color='DarkMagenta', linewidth=1.5) | |
plt.setp(bp['fliers'], color='OrangeRed', marker='o', markersize=10) | |
plt.setp(bp['medians'], color='OrangeRed', linewidth=1.5) | |
colors = ['lightgreen', 'lightblue', 'tan', 'pink'] | |
for patch, color in zip(bp['boxes'], colors): | |
patch.set_facecolor(color) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment