python-3.x - 是否可以使用 Matplotlib 创建 2 边条形图

标签 python-3.x matplotlib bar-chart

是否可以使用 Matplotlib 创建类似的东西(没有渐变颜色或/和每个条上方的数字)我发现的只是如何将图表放在彼此之上。 2-side bar chart

最佳答案

要使用matplotlib.pyplot.hist显示反向直方图,可以使用参数weigths对值赋予负权重。

最小示例:

import numpy as np
import matplotlib.pyplot as plt

x1 = np.random.random(100)
x2 = np.random.random(100)

plt.hist(x1, facecolor='teal', edgecolor='white', range=(0, 1))
plt.hist(x2, fc='tomato', ec='white', weights=np.full(len(x2), -1), range=(0, 1))
plt.show()

enter image description here

关于python-3.x - 是否可以使用 Matplotlib 创建 2 边条形图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61559131/

相关文章:

python pyplot : colorbar on contourf and scatter in same plot

javascript - 在条形之间添加空格/边距 - Chart.js

python - 每个色调带有堆叠条的计数图

javascript - 可重复使用的条形图,显示具有相同名称的条形图

python - Networkx 传播节点和短缺标签

Python 在 MacO 上找不到已安装的模块 slackclient。有什么建议么?

python - 正则表达式匹配单词,如果可选地后跟任何单词,除非后跟某些单词

python-3.x - 从 python 3.6 升级到 3.8 后出现 KeyError(f"None of [{key}] are in the [{axis_name}]")

python - 将颜色条添加到 3 变量颜色图表

python - Ubuntu : error using cv2. imshow() 与 pyplot.plot()