如何创建绘制数字范围的水平条形图?

How to create a horizontal bar graph graphing number ranges?

有谁知道如何创建绘制数字范围的水平条形图?我的意思是,图形值不是从 x 轴 0 上的 0 开始并停止在另一个奇异数处,而是这些值具有表示范围的起始值和结束值。

据我所知,barh 只能绘制奇异值而不是范围值。

我一直在尝试使用 matplotlib's barh 来实现这一点,但是我似乎无法弄清楚如何让它绘制范围。

这是我的意思的一个例子:

任何人都可以告诉我如何使用 matplotlib 或其他替代 Python 模块来绘制它吗?

首先你必须绘制你想看到的条,然后你在其他条上方绘制一个白色条。但这与其说是一个好的解决方案,不如说是一种黑客攻击。

import matplotlib.pyplot as plt
import numpy as np


target_bars_start = [10, 10, 15, 8]
target_bars_end = [15, 23, 16, 10]
N = len(target_bars_end)
ind = np.arange(N)

plt.barh(ind, target_bars_end, 0.35)
plt.barh(ind, target_bars_start, 0.35, color='white')