已解决
利用python绘制多个箱型图
来自网友在路上 174874提问 提问时间:2023-11-01 15:41:41阅读次数: 74
最佳答案 问答题库748位专家为你答疑解惑
文章目录
- 1. 图片
- 2. 代码
1. 图片
图片示例如下所示:
2. 代码
代码如下所示:
# Define the custom order based on atmospheric stability
custom_order = ['vus_0', 'us_1', 'ne_2', 'ws_3', 'ws_4', 's_5', 's_6', 's_7', 'vs_8', 'vs_9']# Step 1: Reorder the statistical summary based on the custom order
grouped_stats_reordered = grouped_stats.loc[custom_order]# Show only a truncated view to not overwhelm the user
grouped_stats_reordered.iloc[:, :8] # Show only some of the columns for a preview
# Step 2: Reorder the boxplots based on the custom order# Set the figure size
plt.figure(figsize=(15, 10))# Subplot for class1
plt.subplot(2, 2, 1)
sns.boxplot(x='MO_label', y='class1', data=df, order=custom_order)
plt.title('Boxplot of class1 grouped by MO_label (Ordered by Atmospheric Stability)')# Subplot for class5
plt.subplot(2, 2, 2)
sns.boxplot(x='MO_label', y='class5', data=df, order=custom_order)
plt.title('Boxplot of class5 grouped by MO_label (Ordered by Atmospheric Stability)')# Subplot for ws120_Avg
plt.subplot(2, 2, 3)
sns.boxplot(x='MO_label', y='ws120_Avg', data=df, order=custom_order)
plt.title('Boxplot of ws120_Avg grouped by MO_label (Ordered by Atmospheric Stability)')# Subplot for TI
plt.subplot(2, 2, 4)
sns.boxplot(x='MO_label', y='TI', data=df, order=custom_order)
plt.title('Boxplot of TI grouped by MO_label (Ordered by Atmospheric Stability)')# Adjust layout
plt.tight_layout()
plt.show()
查看全文
99%的人还看了
相似问题
猜你感兴趣
版权申明
本文"利用python绘制多个箱型图":http://eshow365.cn/6-29417-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!