Skip to content

Instantly share code, notes, and snippets.

@jpigla
Created June 9, 2020 13:46
Show Gist options
  • Save jpigla/f64c4af5526da40c0f46e223c299fb81 to your computer and use it in GitHub Desktop.
Save jpigla/f64c4af5526da40c0f46e223c299fb81 to your computer and use it in GitHub Desktop.
# 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')
@jpigla
Copy link
Author

jpigla commented Jun 9, 2020

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment