import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from scipy.signal import spectrogram
file_path = "DOSYANIZI BURAYA YÜKLEYİN"
data = np.genfromtxt(file_path, delimiter=",", skip_header=2)
time = data[:, 0]
signal_a = data[:, 1]
frequencies, times, spectrogram_data = spectrogram(signal_a, fs=1.0/(time[1]-time[0]))
fig = plt.figure(figsize=(12, 8))
ax = fig.add_subplot(111, projection='3d')
X, Y = np.meshgrid(times, frequencies)
surf = ax.plot_surface(X, Y, 10 * np.log10(spectrogram_data), cmap='viridis', rstride=10, cstride=10, linewidth=0, antialiased=True)
fig.colorbar(surf, ax=ax, label='Güç (dB)')
ax.set_xlabel('Zaman (s)')
ax.set_ylabel('Frekans (Hz)')
ax.set_zlabel('Güç (dB)')
ax.set_title('Geliştirilmiş 3D Spektrogram - Kanal A')
mappable = ax.collections[0]
mappable.set_array(surf.get_array())
mappable.set_clim(-40, np.max(10 * np.log10(spectrogram_data)))
cbar = plt.colorbar(mappable)
cbar.set_label('Güç (dB)', rotation=270, labelpad=15)
ax.view_init(elev=45, azim=-30)
plt.show()