import matplotlib.pyplot as plt vtn = 0.7 vtp = -0.7 vdd = 5 Bn = Bp = 380 vout = [None]*26 vin = [0.0,0.2,0.4,0.6,0.8,1.0,1.2,1.4,1.6,1.8,2.0,2.2,2.4,2.6,2.8,3.0,3.2,3.4,3.6,3.8,4.0,4.2,4.4,4.6,4.8,5.0] for i in range(0,26): if 0<=vin[i]<=vtn : vout[i] = vdd elif vtn <= vin[i] <= vdd / 2: vout[i] = (vin[i] - vtp) + ((vin[i] - vtp) ** 2 - 2 * (vin[i] - vdd / 2 - vtp) * vdd - Bn/Bp * (vin[i] - vtn) ** 2) ** 0.5 elif vin[i] == vdd / 2: vout[i] = vin[i] elif vdd / 2 < vin[i] <= vdd + vtp: vout[i] = (vin[i] - vtn) - ((vin[i] - vtn)** 2 - Bn/Bp * (vin[i] - vdd - vtp)** 2)** 0.5 elif vin[i] > vdd + vtp: vout[i] = 0 plt.plot(vin, vout, marker="o") plt.xlabel("Vin") plt.ylabel("Vout") plt.show() this code in python and out this picture each if statement represent different region I want colored each region in different color please
import matplotlib.pyplot as plt
vtn = 0.7
vtp = -0.7
vdd = 5
Bn = Bp = 380
vout = [None]*26
vin = [0.0,0.2,0.4,0.6,0.8,1.0,1.2,1.4,1.6,1.8,2.0,2.2,2.4,2.6,2.8,3.0,3.2,3.4,3.6,3.8,4.0,4.2,4.4,4.6,4.8,5.0]
for i in range(0,26):
if 0<=vin[i]<=vtn :
vout[i] = vdd
elif vtn <= vin[i] <= vdd / 2:
vout[i] = (vin[i] - vtp) + ((vin[i] - vtp) ** 2 - 2 * (vin[i] - vdd / 2 - vtp) * vdd - Bn/Bp * (vin[i] - vtn) ** 2) ** 0.5
elif vin[i] == vdd / 2:
vout[i] = vin[i]
elif vdd / 2 < vin[i] <= vdd + vtp:
vout[i] = (vin[i] - vtn) - ((vin[i] - vtn)** 2 - Bn/Bp * (vin[i] - vdd - vtp)** 2)** 0.5
elif vin[i] > vdd + vtp:
vout[i] = 0
plt.plot(vin, vout, marker="o")
plt.xlabel("Vin")
plt.ylabel("Vout")
plt.show()
this code in python and out this picture
each if statement represent different region I want colored each region in different color please
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
This just colored the point
I want coloring the line also please
How can I change this color to another color ?