简体   繁体   中英

Python - plot module' object is not callable

Fairly new to Python and receiving error: 'module' object is not callable.

Basically, I have a model with some reactions, I am using a for loop that changes some values of selected reactions and then I want to plot the output of the model as a function of the change in parameter. Perhaps my code will provide more of a concise answer, so here it is:

import cobra
import os
from os.path import join
import matplotlib.pyplot as plt

data_dir = '/Users/stephenchapman/Documents/research/FBA_algae_digesate/COBRApy/iCZ843/iCZ843_models'
model = cobra.io.read_sbml_model(join(data_dir, "iCZ843_mixo.xml"))
NH4_exchange = []
fluxes = []

for i in range(0,100,10):
    model.reactions[15].lower_bound = -i
    model.reactions[15].upper_bound = -i
    solution = model_mixo.optimize()    
    solution.f
    fluxes.append(solution.f)
    NH4_exchange.append(model.reactions[15].lower_bound)
plt('fluxes','NH4_exchange')
plt.show()

Can anyone please help me with this?

Cheers

S.

You want to plot arrays (or lists), not strings.

plt.plot(fluxes, NH4_exchange)

That being said, if you actually wanted to plot strings, they would need to have the same length and be converted to a list first, eg

plt.plot(list("fluxes"), list("change"))

would result in

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM