Created
March 23, 2018 14:34
-
-
Save WillKoehrsen/f07f8f9a84b5518bde45c3fa0727a4e0 to your computer and use it in GitHub Desktop.
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
# Make a separate list for each airline | |
x1 = list(flights[flights['name'] == 'United Air Lines Inc.']['arr_delay']) | |
x2 = list(flights[flights['name'] == 'JetBlue Airways']['arr_delay']) | |
x3 = list(flights[flights['name'] == 'ExpressJet Airlines Inc.']['arr_delay']) | |
x4 = list(flights[flights['name'] == 'Delta Air Lines Inc.']['arr_delay']) | |
x5 = list(flights[flights['name'] == 'American Airlines Inc.']['arr_delay']) | |
# Assign colors for each airline and the names | |
colors = ['#E69F00', '#56B4E9', '#F0E442', '#009E73', '#D55E00'] | |
names = ['United Air Lines Inc.', 'JetBlue Airways', 'ExpressJet Airlines Inc.'', | |
'Delta Air Lines Inc.', 'American Airlines Inc.'] | |
# Make the histogram using a list of lists | |
# Normalize the flights and assign colors and names | |
plt.hist([x1, x2, x3, x4, x5], bins = int(180/15), normed=True, | |
color = colors, label=names) | |
# Plot formatting | |
plt.legend() | |
plt.xlabel('Delay (min)') | |
plt.ylabel('Normalized Flights') | |
plt.title('Side-by-Side Histogram with Multiple Airlines') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment