python - python seaborn.distplot 不正确的图例
问题描述
在 seaborn.distplot 中使用不同的线条样式时,我得到了不正确的图例
这是我的代码:
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
URL = "https://media.githubusercontent.com/media/WillKoehrsen/Data-Analysis/master/univariate_dist/data/formatted_flights.csv"
df = pd.read_csv(URL, index_col=0)
airlines = df['name'].unique().tolist()
LINE_STYLES = ['solid', 'dashed', 'dashdot', 'dotted']
plt.figure(figsize=(15,8))
plt.title('Histogram of Arrival Days', fontsize=18)
plt.xlabel('Delay (min)', fontsize=18)
plt.ylabel('Flights', fontsize=18)
for i, airline in enumerate(airlines):
sns.distplot(df[df['name'] == airline]['arr_delay'], label=airline, bins=int(180/5),
hist=False, kde_kws={'linewidth': 3, 'shade':True, 'linestyle':LINE_STYLES[i%4]})
阿拉斯加航空公司的传说应该是-。(如美国航空公司)但它是 - (如联合航空公司)
解决方案
推荐阅读
- php - 如何添加 Timber dump() 函数
- r - 面板数据中的月协方差计算 -r
- python - /admin/myschoolweb/album/add/ 处的 OperationalError - 没有这样的表:main.auth_user__old
- javascript - 如何在三角形多维数组中填充数字?
- sqlite - 在菜单上调用 startActivity 函数会使应用程序崩溃
- vim - 如何从vim中的跳转列表中删除缓冲区
- c++ - eclipse中的gtest错误:ld.exe找不到-llibgtest
- java - 是否应该将使用 String.indexOf 的 0 长度字符串“”的搜索行为视为未定义?
- hyperledger-fabric - Hyperledger Fabric:如何制作前端?
- c# - 如何设置等待时间等待结果