【问题标题】:How to subplot two histograms with one mirror with respect to the other in Python? [closed]如何在 Python 中用一个镜像相对于另一个镜像绘制两个直方图? [关闭]
【发布时间】:2021-09-26 20:17:22
【问题描述】:

我想将这两个直方图上下合并为一个。

图 1:

图 2:

预期输出:

我该怎么办?

【问题讨论】:

  • 您似乎也反转了 x 轴。这是故意的吗?

标签: python matplotlib merge histogram


【解决方案1】:

没有任何例子很难说。

这里有一些模拟数据:

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

输出:

【讨论】:

    猜你喜欢
    • 2010-12-15
    • 2021-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多