我试图将值标签bold仅放置在每个水平条的右侧,在seaborn的条形图中,但我无法将它们放置在条形图之外,值以正常的fontweight显示。你知道吗
我试着调整少数几个没有成功matplotlib.pyplot.text文件参数,但我找不到解决问题的钥匙。你知道吗
这是代码的特定部分:
plt.figure()
ax = sb.barplot(x='count', y='location', data=plocat.iloc[:10,:], palette=('BrBG_r'))
ax.set_xlabel('Posted jobs per location')
ax.set_ylabel('') # Remove y axis label
ax.set_xticklabels('') # Remove x values
a = plt.gca()
for p in a.patches:
a.text(p.get_width(), p.get_y() + p.get_height()/2., '%d' % int(p.get_width()),
fontsize=9, fontweight='bold', ha='right', va='center')
plt.box(on=None) # Remove black frame
plt.tight_layout()
plt.savefig('./imgs/toplocations.png', dpi=300)
下面的URL显示了我得到的绘图:https://cdn1.imggmi.com/uploads/2019/5/13/f97b7ec0fc9a7eb951b42ed3b1de03b4-full.png
提前谢谢!你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐