我使用以下方法 boxplot 功能来自 Pandas ,
boxplot
df.boxplot(column=['D1', 'D2'])
我想改变y轴的范围。然而,我在文件中没有看到这样的选项。有什么想法吗?
可以编辑axis对象,也可以
ax = df.boxplot(column=['D1', 'D2']) ax.set_ylim(0, 10)
或
import matplotlib.pyplot as plt fix, ax = plt.subplots(1, 1) df.boxplot(column=['D1', 'D2'], ax=ax) ax.set_ylim(0, 10)
figure是整个图形,ax是图表。 plt.subplots(1, 1) 是图(行、列)的数量,在本例中为1——因此ax只是一个图。否则ax将是axis对象的列表。
plt.subplots(1, 1)