Xtick频率(在boxp中)

2024-04-20 14:00:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用pandas groupby绘制风速与风向的关系,使用条形图和胡须图。然而,X轴是不可读的,因为许多风向值彼此接近。你知道吗

我已经尝试过oc_params ax.set_xticks,但是取而代之的是具有不同值的空x轴或修改的xaxis

我的数据帧的头

    Kvit_TIU     dir_cat  
0   0.064740         14  
1   0.057442         15  
2   0.056750         15  
3   0.069002         17  
4   0.068464         17  
5   0.067057         17  
6   0.071901         12  
7   0.050464          5  
8   0.066165          1  
9   0.073993         27  
10  0.090784         34  
11  0.121366         33  
12  0.087172         34  
13  0.066197         30  
14  0.073020         17  
15  0.071784         16  
16  0.081699         17  
17  0.088014         14  
18  0.076758         14  
19  0.078574         14  

我用groupby = dir_cat创建了一个方框图

fig = plt.figure() # create the canvas for plotting
ax1 = plt.subplot(1,1,1) 
ax1 = df_KvTr10hz.boxplot(column='Kvit_TIU', by='dir_cat', showfliers=False, showmeans=True)
ax1.set_xticks([30,90, 180,270, 330])

我想把x轴的频率降低。以便绘图可读 unreadable plotusing ax1.set_xticks

enter image description here

enter image description here


Tags: pandas关系dir绘制pltcat条形图groupby