我试图在matplotlib中绘制一个分段函数。我的过滤方法(基于Ami的回答here)不起作用:
ValueError: x and y must have same first dimension
你能解决这个问题吗?
import numpy as np
import matplotlib.pyplot as plt
gK_inf = 7.06
gK_0 = 0.09
tauN = 0.75
gK_inf1 = 0.09
gK_01 = 7.06
tauN1 = 1.1
def graph(formula, formula1, t_range):
t = np.fromiter(t_range, np.float)
gK = formula(t)
gK1 = formula1(t)
plt.plot(t,gK)
plt.plot(t,gK1)
plt.xlabel(r"$t(msec.)$")
plt.ylabel(r"$g_K$")
plt.show()
def my_formula(t):
if np.all(t>0) and np.all(t<5):
return np.power((np.power(gK_inf,0.25))-((np.power(gK_inf,0.25)-np.power(gK_0,0.25))*np.exp(-t/tauN)),4)
else:
return 0
def my_formula1(t):
if np.all(t>5) and np.all(t