更改matplotlib中的数字大小

发布于 2025-01-25 23:27:05 字数 736 浏览 3 评论 0原文

这是我的代码,我想使剧情更大,以便更容易阅读。在这里,我试图基于杂质的平均减少而获得特征重要性。我得到了一些输出,但是由于我的Barplot有63个垃圾箱,所以我希望它更大。我尝试了所评论的所有内容。有人可以建议我如何使该栏图更可读吗?

import pandas as pd
from matplotlib.pyplot import figure

# fig.set_figheight(20)
# fig.set_figwidth(20)
#plt_1 = plt.figure(figsize=(20, 15), dpi = 100)

forest_importances = pd.Series(importances, index=feature_names)
fig, ax = plt.subplots()
forest_importances.plot.bar(yerr=std, ax=ax)
ax.set_title("Feature importances using MDI")
ax.set_ylabel("Mean decrease in impurity")

# fig = plt.figure()

fig.tight_layout()
plt.show()

This is my code and I want to make the plot bigger so it's easier to read. Here I'm trying to get feature importance based on mean decrease in impurity. I'm getting some output but since my barplot has 63 bins, I want it much bigger. I tried everything that is commented. Can someone please suggest how can I make this bar plot more readable? enter image description here

import pandas as pd
from matplotlib.pyplot import figure

# fig.set_figheight(20)
# fig.set_figwidth(20)
#plt_1 = plt.figure(figsize=(20, 15), dpi = 100)

forest_importances = pd.Series(importances, index=feature_names)
fig, ax = plt.subplots()
forest_importances.plot.bar(yerr=std, ax=ax)
ax.set_title("Feature importances using MDI")
ax.set_ylabel("Mean decrease in impurity")

# fig = plt.figure()

fig.tight_layout()
plt.show()

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

捂风挽笑 2025-02-01 23:27:05

使用图.set_size_inches plt.show()

width = 8
height = 6
fig.set_size_inches(width, height)

Use fig.set_size_inches before plt.show():

width = 8
height = 6
fig.set_size_inches(width, height)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文