是否可以使用Matplotlib创建2边条形图

问题描述 投票:0回答:1

是否有可能使用Matplotlib创建类似的东西(在每个小节上方都没有渐变颜色或/和数字),我发现的所有内容都是如何将图表相互叠加。2-side bar chart

python-3.x matplotlib bar-chart design
1个回答
0
投票

要使用matplotlib.pyplot.hist显示反向直方图,可以将负权重设置为值。

最小示例:

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

© www.soinside.com 2019 - 2024. All rights reserved.