Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb44bfff

Browse files
author
minjk-bl
committed
Add show values inner function
1 parent7ddc806 commitb44bfff

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

‎python/userCommand.py‎

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,42 @@ def vp_plot_feature_importances(model, X_train=None, sort=False):
8989
_vp_plt.xlabel('Feature importance Percentage')
9090
_vp_plt.ylabel('Features')
9191

92-
_vp_plt.show()
92+
_vp_plt.show()
93+
######
94+
# Visual Python: Visualization > Seaborn
95+
######
96+
defvp_seaborn_show_values(axs,precision=1,space=0.01):
97+
pstr='{:.'+str(precision)+'f}'
98+
99+
def_single(ax):
100+
# check orient
101+
orient='v'
102+
iflen(ax.patches)==1:
103+
# check if 0
104+
ifax.patches[0].get_x()==0:
105+
orient='h'
106+
else:
107+
# compare 0, 1 patches
108+
p0=ax.patches[0]
109+
p1=ax.patches[1]
110+
ifp0.get_x()==p1.get_x():
111+
orient='h'
112+
113+
iforient=='v':
114+
forpinax.patches:
115+
_x=p.get_x()+p.get_width()/2
116+
_y=p.get_y()+p.get_height()+ (p.get_height()*space)
117+
value=pstr.format(p.get_height())
118+
ax.text(_x,_y,value,ha='center')
119+
eliforient=='h':
120+
forpinax.patches:
121+
_x=p.get_x()+p.get_width()+ (space-0.01)
122+
_y=p.get_y()+p.get_height()/2
123+
value=pstr.format(p.get_width())
124+
ax.text(_x,_y,value,ha='left')
125+
126+
ifisinstance(axs,_vp_np.ndarray):
127+
foridx,axin_vp_np.ndenumerate(axs):
128+
_single(ax)
129+
else:
130+
_single(axs)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp