'How to make spectrogram smoothening?
Guys first teach me how to attach my data with question. I do not find it.
I attached two figures, One that I plotted and other that is my reference figure.
Below is the command for generating the figure. I have two problems:
- I see that the plot which I have made is not so smooth as given in the reference.
- The y-scale of my plot is does not align with the reference figure.
Can anyone please help me with this?
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import FormatStrFormatter
from scipy import signal
from matplotlib import colors
t1 = np.loadtxt('t1.txt')
t1 = t1*3600
Btot1 = np.loadtxt('Btot2.txt')
fs = 40
x = Btot1
axis_font = {'fontname':'Arial', 'size':'14','weight':'bold', 'color':'black'}
fig, axs = plt.subplots(2, sharex=True, sharey=True, gridspec_kw={'hspace': 0.2},figsize=(10,10))
op_f, op_t, op_Sxx = signal.spectrogram(x, fs, scaling = 'spectrum', nperseg = 4096, noverlap=512)
plt.pcolormesh(op_t, op_f, op_Sxx, shading='auto', cmap = 'jet', norm=colors.LogNorm(1e-5, 1e0))
plt.ylabel('Frequency [Hz]')
plt.xlabel('Time [sec]')
plt.ylim([0, 2])
plt.colorbar()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


