【发布时间】:2021-09-26 20:17:22
【问题描述】:
我想将这两个直方图上下合并为一个。
图 1:
图 2:
预期输出:
我该怎么办?
【问题讨论】:
-
您似乎也反转了 x 轴。这是故意的吗?
标签: python matplotlib merge histogram
我想将这两个直方图上下合并为一个。
图 1:
图 2:
预期输出:
我该怎么办?
【问题讨论】:
标签: python matplotlib merge histogram
没有任何例子很难说。
这里有一些模拟数据:
import matplotlib.pyplot as plt
import numpy as np
xaxis = np.array(([1,2,3,4,5]))
x1 = np.array(([6,7,8,9,10]))
x2 = np.array(([10,9,8,7,6]))
fig, ax = plt.subplots()
ax.bar(xaxis, x1) #blue bar
ax.bar(xaxis, -x2) #orange bar
ax.vlines(xaxis, -x2, x1) #alternatively black line, remove this if not needed
【讨论】: