enter image description here我正在尝试在3D交互式图中绘制频谱图。但我无法
我对这里的问题有类似的疑问:How to convert a spectrogram to 3d plot. Python 但是我相信找不到很好的答案
,我也检查了这一点: Dynamic spectrum using plotly 但是代码没有与我一起编译。
'''python
import matplotlib.pyplot as plt
import numpy as np
# Fixing random state for reproducibility
np.random.seed(19680801)
dt = 0.0005
t = np.arange(0.0, 20.0, dt)
s1 = np.sin(2 * np.pi * 100 * t)
s2 = 2 * np.sin(2 * np.pi * 400 * t)
# create a transient "chirp"
s2[t <= 10] = s2[12 <= t] = 0
# add some noise into the mix
nse = 0.01 * np.random.random(size=len(t))
x = s1 + s2 + nse # the signal
NFFT = 1024 # the length of the windowing segments
Fs = int(1.0 / dt) # the sampling frequency
fig, (ax1, ax2) = plt.subplots(nrows=2)
ax1.plot(t, x)
Pxx, freqs, bins, im = ax2.specgram(x, NFFT=NFFT, Fs=Fs,
noverlap=900)
# The `specgram` method returns 4 objects. They are:
# - Pxx: the periodogram
# - freqs: the frequency vector
# - bins: the centers of the time bins
# - im: the matplotlib.image.AxesImage instance representing the data
in the plot
plt.show()
# Plot with plotly
trace = [go.Heatmap(
x= bins,
y= freqs,
z= 10*np.log10(Pxx),
colorscale='Jet',
)]
layout = go.Layout(
title = 'Spectrogram with plotly',
yaxis = dict(title = 'Frequency'), # x-axis label
xaxis = dict(title = 'Time'), # y-axis label
)
fig = go.Figure(data=trace, layout=layout)
pyo.iplot(fig, filename='Spectrogram')
'''
因此,我以文档为例来生成成功的频谱图,但是我无法将其制作为3d图。 理想情况下,我想使其成为交互式3d图。我曾尝试在离线模式下使用plotly。不幸的是,剧情不是生成的
我是python 3d绘图的新手,任何帮助将不胜感激
这是我得到的错误:
“ IOPub数据速率已超过。
笔记本服务器将暂时停止发送输出
以避免崩溃。
要更改此限制,请设置config变量
--NotebookApp.iopub_data_rate_limit
。”