q从常量改变成随时间变化的sin函数,怎么改写python代码?如题,将q变成q=sin(ommiga*t),t取四个值,ommiga取一个定值,都可以随意取值,没有要求
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
from sympy.solvers import solve
from sympy import Symbol
from matplotlib import patches
import matplotlib.patches as mpatches
import scipy.io as sio
# plotting configuration
ratio = 1.5
figure_len, figure_width = 15*ratio, 12*ratio
font_size_1, font_size_2 = 36*ratio, 36*ratio
legend_size = 18*ratio
line_width, tick_len = 3*ratio, 10*ratio
marker_size = 15*ratio
plot_line_width = 5*ratio
hfont = {'fontname': 'Arial'}
l_color = ['#D6EAF8', '#85C1E9', '#3498DB', '#2874A6']
a = 1.8
b = 1.0
c = 1.0
d = 0.6
n = 2
l_q = [0.75, 1.5, 2.25, 3]
p = 2
plt.figure(figsize=(figure_len, figure_width))
ax = plt.gca()
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['bottom'].set_visible(True)
ax.spines['left'].set_visible(True)
for axis in ['top', 'bottom', 'left', 'right']:
ax.spines[axis].set_linewidth(line_width)
plt.tick_params(width=line_width, length=tick_len)
for q_idx in range(len(l_q)):
q = l_q[q_idx]
x = np.arange(0, 10, 0.001)
detM = -a * d + b * c
C_p = -(1 / b) * d * q + p
N = detM * (1 / b) * np.power(x, 2) + (1 / b) * d * x + C_p
y = a * np.power(x, 2) - b * np.power(N * (N > 0), 2) - x + q
plt.plot(x, y, color=l_color[q_idx], linewidth=plot_line_width)
plt.hlines(y=0, xmin=0, xmax=3, colors='k', linestyles=[(0, (6, 6, 6, 6))], linewidth=line_width)
plt.xlabel(r'$x$', fontsize=font_size_1, **hfont)
plt.ylabel(r'$y$', fontsize=font_size_1, **hfont)
plt.xticks([0, 1, 2, 3], fontsize=font_size_1, **hfont)
plt.yticks([-5, 0, 5, 10, 15], fontsize=font_size_1, **hfont)
plt.xlim([0, 3])
plt.ylim([-5, 15])
plt.legend([r'$q$: 0.75', r'$q$: 1.5', r'$q$: 2.25', r'$q$: 3.0'], prop={"family": "Arial", 'size': font_size_1}, loc='upper right')
plt.savefig('1.png')
plt.savefig('2.pdf')