Posted: 7/4/2020
I was wondering if anyone knows how to plot a sine wave with let\'s say amplitude of 0.1 as a start and then continuing on as usual. Until at one point,
You could plot a piece-wise sin
function where the second part defines the surge happening and you can change the amplitude there.
For instance:
import numpy as np
import matplotlib.pyplot as plt
import math
surge_point = 50
amplitudeAfterSurge = 4
T = 50
x_normal = np.linspace(0, surge_point, 1000)
x_surge = np.linspace(surge_point, 150, 1000)
y_normal = [math.sin(2*math.pi*i/T) for i in x_normal] # first part of the function
# second part ,note `amplitudeAfterSurge` multiplying the function
y_surge = [amplitudeAfterSurge * math.sin(2*math.pi*i/T) for i in x_surge]
plt.plot(x_normal, y_normal , 'r')
plt.plot(x_surge, y_surge , 'r')
plt.show()
And you will get: