Created
March 24, 2018 02:06
-
-
Save breeko/297ae0060f45ea406970f51604a3a266 to your computer and use it in GitHub Desktop.
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
| # Define colors to be used in visualizations | |
| colors = {"A": "darkseagreen", "B": "dodgerblue", "C": "lightcoral", "P": "wheat", "Z": "lightgrey", "Not Yet Graded": "lightgrey"} | |
| # Bar graph based on scores, segmented by grade | |
| f, axes = plt.subplots(nrows=2,ncols=3,figsize=(12,7)) | |
| axes[0][0].hist(df[(df.SCORE > 0) & (df.SCORE < 50)].SCORE,bins=50, color="grey",alpha=0.5) | |
| axes[0][0].set_title("ALL") | |
| for ax, boro in zip(axes.ravel()[1:], df.BORO.unique()): | |
| ax.hist(df[(df.SCORE > 0) & (df.SCORE < 50) & (df.BORO == boro)].SCORE,bins=50, color="grey",alpha=0.5) | |
| ax.set_title(boro) | |
| for ax in axes.ravel(): | |
| ax.axvline(13,color=colors["A"],linestyle="-") | |
| ax.text(0.12, 0.85,"A",color=colors["A"],transform=ax.transAxes,fontsize=20) | |
| ax.axvline(27,color=colors["B"],linestyle="-") | |
| ax.text(0.35, 0.85,"B",color=colors["B"],transform=ax.transAxes,fontsize=20) | |
| ax.text(0.7, 0.85,"C",color=colors["C"],transform=ax.transAxes,fontsize=20) | |
| ax.set_xlabel("Score") | |
| plt.tight_layout() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment