如何在matplotlib中正确绘制dBc值?

2024-04-18 23:40:53 发布

您现在位置:Python中文网/ 问答频道 /正文

所以我想画出均衡器抽头的振幅,像这样:

enter image description here

但是我所有的均衡器抽头振幅都是-dBc(负dB载波)。我当前的代码如下所示:

self.ui.mplCoeff.canvas.ax.clear()
rect = 1,24,-100,0
self.ui.mplCoeff.canvas.ax.axis(rect)
self.ui.mplCoeff.canvas.ax.bar(tapIndices,tapAmplitudedBc)

结果如下所示,基本上和我需要的相反。有人有线索吗?你知道吗

enter image description here


Tags: 代码rectselfuidbbaraxdbc
1条回答
网友
1楼 · 发布于 2024-04-18 23:40:53

让我先用一些示例数据创建一些类似于您的绘图的内容:

import numpy as np
import matplotlib.pyplot as plt

x = np.arange(11)
y = - x**2
plt.bar(x, y)

这将产生以下图像:

Plot like in question

现在可以使用^{}bottom参数将图像转换为所需的图像:

plt.bar(x, 100 + y, bottom = -100)
# or, more general:
# plt.bar(x, -m + y, bottom = m)
# where m is the minimum value of your value array, m = np.min(y)

塔达:

Better plot

相关问题 更多 >