如何将轴标签添加到 python 中的箱形图中?

How do I add axis labels to my box plot in python?

如何在 x 轴和 y 轴上添加标签?

这是我的地块的 python 代码:

fd = pd.read_csv('FD_IWS1.csv')
fd = fd.loc[fd['FD1'] * fd['FD2'] * fd['FD3'] * fd['FD4'] * fd['FD5'] != 0]
boxplot = fd.boxplot(grid=False, rot=45, fontsize=15)

我需要添加什么才能获得标签?

您可以使用 matplotlib.pyplot.xlabel("label")。例如(我使用随机值,因为我没有你的 csv):

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

df = pd.DataFrame(np.random.rand(5, 2), columns=['A', 'B'])
boxplot = df.boxplot(grid=False, rot=45, fontsize=15)

plt.xlabel("Label of X axis")

bplot=sns.boxplot(data=fd, width=0.5, showfliers=False) bplot.set_title("30 cm Sensor Data", fontsize=16) bplot.set_xlabel("Column", fontsize=14) bplot.set_ylabel("Soil Moisture Level (w/v)", fontsize=14) bplot