所以我在一个 Dataframe 上有大量的数据,我想可视化它。
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(6, 6))
colors = {'Sunny':'tab:blue', 'Hurricane':'tab:orange', 'Cloudy':'tab:green', 'Rain':'tab:red', 'Foggy':'tab:purple', 'Storm':'tab:brown'}
grouped = df.groupby('Climate')
for key, group in grouped:
group.plot(ax=ax, kind='scatter', x='month', y='eta/km*100', label=key, color=colors[key])
plt.xticks(range(1, 13))
plt.show()
问题是它看起来像这样:
正如你所看到的,多云,有雾和下雨不能被看到,因为有一些数据在他们面前。我可以尝试迫使他们显示在前面,但其他气候不会被看到。
什么是最好的解决方案呢?我不知道是否有可能移动每种类型的天气一些像素的X轴,以便能够看到所有的数据,但仍然有他们在同一个月或类似的东西,谢谢!
1条答案
按热度按时间chhqkbe11#
正如@mozway所说,解决方案是使用stripplot
我实现的代码:
情节: