Skip to content

Instantly share code, notes, and snippets.

@WillKoehrsen
Created March 23, 2018 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WillKoehrsen/58d97c1ecc51354736314b3f5cdef3dc to your computer and use it in GitHub Desktop.
Save WillKoehrsen/58d97c1ecc51354736314b3f5cdef3dc to your computer and use it in GitHub Desktop.
# List of five airlines to plot
airlines = ['United Air Lines Inc.', 'JetBlue Airways', 'ExpressJet Airlines Inc.'',
'Delta Air Lines Inc.', 'American Airlines Inc.']
# Iterate through the five airlines
for airline in airlines:
# Subset to the airline
subset = flights[flights['name'] == airline]
# Draw the density plot
sns.distplot(subset['arr_delay'], hist = False, kde = True,
kde_kws = {'linewidth': 3},
label = airline)
# Plot formatting
plt.legend(prop={'size': 16}, title = 'Airline')
plt.title('Density Plot with Multiple Airlines')
plt.xlabel('Delay (min)')
plt.ylabel('Density')
@anshulxyz
Copy link

there's a slight typo

- airlines = ['United Air Lines Inc.', 'JetBlue Airways', 'ExpressJet Airlines Inc.'',
+ airlines = ['United Air Lines Inc.', 'JetBlue Airways', 'ExpressJet Airlines Inc.',

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