bho*_*sad 2 python pandas seaborn
有什么方法可以在 Seaborn 中创建区域图。我查看了文档,但找不到。
这是我想要绘制的数据。
year_countries.head()
Out[19]:
state_code China France Japan Russia United States
launch_year
1957 0 0 0 2 1
1958 0 0 0 5 22
1959 0 0 0 4 18
1960 0 0 0 8 29
1961 0 0 0 9 41
Run Code Online (Sandbox Code Playgroud)
我使用此代码创建了一个线图 -
sns.relplot(data=year_countries, kind='line',
height=7, aspect=1.3,linestyle='solid')
plt.xlabel('Lanuch Year', fontsize=15)
plt.ylabel('Number of Launches', fontsize=15)
plt.title('Space Launches By Country',fontsize=17)
plt.show()
Run Code Online (Sandbox Code Playgroud)
但是当使用折线图时,情节不是那么清楚 - Plot fig。
也无法根据值按降序对图例进行实体化和排序。
谁能帮我这个?
Jos*_*der 10
使用 Seaborn 风格的 Pandas areaplot 怎么样?
此外,您需要自己对图例进行排序,我从这里获取了示例代码。
plt.style.use('seaborn')
year_countries.plot.area()
plt.xlabel('Launch Year', fontsize=15)
plt.ylabel('Number of Launches', fontsize=15)
plt.title('Space Launches By Country',fontsize=17)
ax = plt.gca()
handles, labels = ax.get_legend_handles_labels()
labels, handles = zip(*sorted(zip(labels, handles), key=lambda t: t[0], reverse=True))
ax.legend(handles, labels)
plt.show()
Run Code Online (Sandbox Code Playgroud)
输出:
| 归档时间: |
|
| 查看次数: |
11769 次 |
| 最近记录: |