0

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.

4
  • 2
    You probably mean plt.plot('fluxes','NH4_exchange') or something instead of plt('fluxes','NH4_exchange') Commented May 10, 2018 at 21:55
  • Hi Sacul, thanks for the reply, I see the difference: Did as suggested and received error: ValueError: Unrecognized character N in format string Commented May 10, 2018 at 22:05
  • Sounds like there is an issue with the data you're trying to plot (some element matplotlib doesn't know what to do with). Can't really help you unless you post a minimal reproducible example Commented May 10, 2018 at 22:08
  • 1
    just remove the quotes around fluxes and NH4_exchange. They are variables, not strings. Commented May 10, 2018 at 22:27

1 Answer 1

1

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, e.g.

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

would result in

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.