<jupyter_start><jupyter_text>Visualization for Science3D Plot        www.data4sci.com            @bgoncalves, @data4sci<jupyter_code>import numpy as np

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

%matplotlib inline<jupyter_output><empty_output><jupyter_text>Generate some fake data<jupyter_code>t_max = 4 # signal duration (seconds)
sample_freq = 250 # points per second
N = t_max*sample_freq
t = np.linspace(0, t_max, N)
amp = np.array([1, .3, .1])
freq = np.array([1, 2, 10])<jupyter_output><empty_output><jupyter_text>Combine all the components into the total signal<jupyter_code>total = np.zeros(1000)
components = []

n_freq = len(freq)

for i in range(n_freq):
    current = amp[i]*np.cos(2*np.pi*freq[i]*t)
    total += current
    
    components.append(current)<jupyter_output><empty_output><jupyter_text>Get the color cycle<jupyter_code>colors = plt.rcParams['axes.prop_cycle'].by_key()['color']<jupyter_output><empty_output><jupyter_text>Vizualize in 3D<jupyter_code>fig = plt.figure(figsize=(16, 16))
ax = fig.add_subplot(111, projection='3d')
ax.set_xlabel("\n\nTime (s)", fontsize=24)
ax.set_ylabel("\n\nFrequency (Hz)", fontsize=24)
ax.set_zlabel("\n\nAmplitude", fontsize=24)

n_freq = np.max(freq)+2
x = np.linspace(0, 4, 1000)
y = np.ones(x.size)

# Plot the total signal
ax.plot(x, y*n_freq, total, linewidth=3, color=colors[1])

# Plot the amplitudes
z = np.zeros(n_freq*100)
z[freq*100] = amp

ax.plot(np.zeros(n_freq*100), np.linspace(0, n_freq, n_freq*100), z, linewidth=3, color=colors[3])

# Plot the components
y = np.ones(1000)
for i in range(0, len(components)):
    ax.plot(x, y*freq[i], components[i], linewidth=1.5, color=colors[0])

plt.setp(ax.get_xticklabels(), fontsize=18)    
plt.setp(ax.get_yticklabels(), fontsize=18)    
plt.setp(ax.get_zticklabels(), fontsize=18)    

ax.set_yticks(freq)
ax.set_yticklabels(freq)
ax.set_xlim(0, t_max)
ax.set_ylim(0, n_freq)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15313935681470137, 'fraction_numerical': 0.039305768249106685, 'mean_word_length': 6.0, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '224507', 'license': 'MIT', 'n_tokens_mistral': 856, 'n_tokens_neox': 811, 'n_words': 143, 'path': '3D Plot.ipynb', 'repo_name': 'DataForScience/Viz4Sci', 'size': '1959'}