Skip to content

Instantly share code, notes, and snippets.

@OmarAlkousa
Created January 25, 2023 11:17
Show Gist options
  • Save OmarAlkousa/3f7d8e9784129cc9d9c1211d54a652ab to your computer and use it in GitHub Desktop.
Save OmarAlkousa/3f7d8e9784129cc9d9c1211d54a652ab to your computer and use it in GitHub Desktop.
This gist is to represent how to generate a simple sine wave using numpy package and plot the results using matplotlib.
# Import the required packages
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('seaborn-poster')
%matplotlib inline
# Generate a vector with 200 sample from 0 to 20
x = np.linspace(0,20,200)
# Generate the sine wave of x variables
y = np.sin(x)
# Plot the generated singal
plt.figure(figsize=(8,8))
plt.plot(x, y, 'b')
plt.xlabel('Location (x)')
plt.ylabel('Amplitude')
plt.title('This is a sine signal')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment