python直方图【色卡】

python直方图【色卡】

直方图code

import matplotlib.pyplot as plt
import os  # 文件保存所需头文件
# 横坐标
x = [0.1430848603, 0.0882253359, 0.0563979112, 0.0458832019, 0.0442359346,
     0.0435552462, 0.0393077842, 0.0387827515, 0.0384597305, 0.0344006384]
# 纵坐标
y = [3, 34, 53, 21, 29, 58, 14, 81, 12, 58]
# 每个柱的颜色设置
color = ['steelblue', 'cornflowerblue', 'royalblue', 'lightsteelblue', 'slateblue', 'mediumslateblue', 'mediumpurple', 'darkslateblue', 'plum', 'thistle']
plt.barh(range(10), importance, height=0.6, color=color, alpha=0.8)      # 从下往上画
plt.yticks(range(10), features)
plt.xlim(0, 0.2)
plt.xlabel('x')
plt.ylabel('y')
plt.title("bar")
# 将值显示于图片
for x, y in enumerate(importance):
    plt.text(y, x, '%s' % y)
plt.show()

#图片保存
dir = 'F:\picture\\'
plt.savefig(os.path.join(save_dir, '1.png'))

结果

result

色卡

在这里插入图片描述
参考链接:

  1. https://blog.csdn.net/xjl271314/article/details/80295935.

  2. https://blog.csdn.net/qq_45269147/article/details/105732597.

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值