在 Pandas.boxplot() 中更改 y 轴范围
Change y-axis range in Pandas.boxplot()
我使用 Pandas、
中的以下 boxplot
函数
df.boxplot(column=['D1', 'D2'])
我想更改 y 轴范围。但是,我在文档中没有看到这样的选项。有什么想法吗?
您可以编辑 axis-object - 您可以这样做
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 将是轴对象的列表。
我使用 Pandas、
中的以下boxplot
函数
df.boxplot(column=['D1', 'D2'])
我想更改 y 轴范围。但是,我在文档中没有看到这样的选项。有什么想法吗?
您可以编辑 axis-object - 您可以这样做
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 将是轴对象的列表。