Home > Blockchain >  numpy and matplot - plotting on the same graph while one element changes
numpy and matplot - plotting on the same graph while one element changes

Time:11-26

I'm trying to create a graph with k_b as the x-value and delta_P as the y-value. I want to plot k_b against delta_P but S=3 for one curve and S=0.1 for another curve. However, I want the two lines to be on the same graph. Does anyone have any advice on how to do that? Below is what I have for S=3 and it works.

def rocproduct(k_cat,E0,S,k_b,k_f):
    return k_cat*E0*S/((k_b/k_f) S)

import numpy as np
import matplotlib.pyplot as plt
k_cat=0.1;E0=1;k_f=0.3;S=3

k_b=np.array([0.01,0.1,0.2,0.5,1,1.5,2,5,10])
delta_P=rocproduct(k_cat,E0,S,k_b,k_f)

plt.ylabel('rate of change of product')
plt.xlabel('kb')
plt.plot(k_b,delta_P)

CodePudding user response:

Just call rocproduct for S=0.1 and plot it again

import numpy as np
import matplotlib.pyplot as plt

# Parameters
k_cat=0.1
E0=1
k_f=0.3
S=3

# Function for data
def rocproduct(k_cat,E0,S,k_b,k_f):
    return k_cat*E0*S/((k_b/k_f) S)

# Data to plot
k_b=np.array([0.01,0.1,0.2,0.5,1,1.5,2,5,10])
delta_P_1=rocproduct(k_cat,E0,S,k_b,k_f)
S = 0.1
delta_P_2=rocproduct(k_cat,E0,S,k_b,k_f)

# Plotting
plt.ylabel('rate of change of product')
plt.xlabel('kb')
plt.plot(k_b,delta_P_1)
plt.plot(k_b, delta_P_2)
plt.show()
  • Related