python直方图【色卡】

这篇博客展示了如何使用Python的matplotlib库绘制直方图,并详细解释了代码中的各个参数,包括设置横纵坐标、柱状颜色、图例及显示数值等。通过示例代码,读者可以了解到如何自定义直方图的视觉效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.youkuaiyun.com/xjl271314/article/details/80295935.

  2. https://blog.youkuaiyun.com/qq_45269147/article/details/105732597.

02-23 16:07:03.866 INFO ==========> LedSnapshotTest <========== 02-23 16:07:13.222 INFO [Test] test_led_snapshot 02-23 16:07:49.331 ERROR Exception occurred in test_led_snapshot. Traceback (most recent call last): File “/home/its/anaconda3/lib/python3.12/site-packages/mobly/base_test.py”, line 818, in exec_one_test test_method() File “/home/its/0.ITS/15R2/android-cts15-r2-verifier/android-cts-verifier/CameraITS/tests/scene_flash/test_led_snapshot.py”, line 264, in test_led_snapshot raise AssertionError(‘\n’.join(failure_messages)) AssertionError: R/G ratio: 3.163611974354118 not within the limits. Format: yuv, Size: 640x480 B/G ratio: 3.163611974354118 not within the limits. Format: yuv, Size: 640x480 Flash image mean not within limits for channel R. Format: yuv,Size: 640x480 Flash image mean not within limits for channel G. Format: yuv,Size: 640x480 Flash image mean not within limits for channel B. Format: yuv,Size: 640x480 R/G ratio: 3.317438224350318 not within the limits. Format: yuv, Size: 256x144 B/G ratio: 3.317438224350318 not within the limits. Format: yuv, Size: 256x144 Flash image mean not within limits for channel R. Format: yuv,Size: 256x144 Flash image mean not within limits for channel G. Format: yuv,Size: 256x144 Flash image mean not within limits for channel B. Format: yuv,Size: 256x144 02-23 16:07:49.332 INFO [Test] test_led_snapshot FAIL 02-23 16:07:49.352 INFO Summary for test class LedSnapshotTest: Error 0, Executed 1, Failed 1, Passed 0, Requested 1, Skipped 0 02-23 16:07:49.352 INFO Summary for test run TEST_BED_SENSOR_FUSION@02-23-2025_16-07-03-865: Total time elapsed 45.48659456789028s Artifacts are saved in “/tmp/CameraITS_99tftggi/cam_id_0/scene_flash/TEST_BED_SENSOR_FUSION/02-23-2025_16-07-03-865” Test summary saved in “/tmp/CameraITS_99tftggi/cam_id_0/scene_flash/TEST_BED_SENSOR_FUSION/02-23-2025_16-07-03-865/test_summary.yaml” Test results: Error 0, Executed 1, Failed 1, Passed 0, Requested 1, Skipped 0这个测试项报错,有修改方式吗
03-15
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值