简体   繁体   English

有没有办法可以使用 Matplotlib plot 数组的不同元素?

[英]Is there a way I can plot different elements of an array using Matplotlib?

I have the following array:我有以下数组:

popul_num = np.array([200, 100, 0, 0])

Each element of the array represents the number of Enzyme, substrate, Enzyme-substrate complex and product in the system.阵列的每个元素代表系统中酶、底物、酶-底物复合物和产物的数量。

I have written code to simulate the following reactions over time and update popul_num to change the values of each entity as it is either consumed or produced:我编写了代码来模拟随着时间的推移发生的以下反应,并更新 popul_num 以在每个实体被消耗或产生时更改它的值:

E + S --> ES E + S --> ES

ES --> E + S ES --> E + S

ES --> E + P ES --> E + P

The functions then update the popul_num array with new values according to the above reactions having happened.然后,这些函数根据发生的上述反应用新值更新 popul_num 数组。

I'm trying to use Matplotlib to plot a line graph of the changes in entity numbers over time as a result of the above reactions occurring我正在尝试使用 Matplotlib 到 plot 作为上述反应发生的结果实体编号随时间变化的折线图

I've tried calling plt.plot once for each index of the array:我尝试为数组的每个索引调用一次 plt.plot :

plt.plot(popul_num[i]) # i in place of each index 

and I've tried:我试过了:

plt.plot(popul_num[0:3]) 

but both methods always just return a one line plot, what am I doing wrong?但是这两种方法总是只返回一行 plot,我做错了什么?

Cheers干杯

You need to store the new state rather than updating it.您需要存储新的 state 而不是更新它。

popul_num = np.array([200, 100, 0, 0])

#after single reaction

popul_num = np.array([200, 100, 0, 0], [300, 50, 2, 4])

# now plot 4 separate graphs

for i in range(4):
 plt.plot(list(enumerate(popul_num[:, i])))

plt.show()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何让 matplotlib 忘记删除的 plot 元素? - How can I make matplotlib forget about removed plot elements? plot 中的日期如何用不同于英语的另一种语言书写? (我正在使用 matplotlib.dates) - How can the dates in a plot be written in another language different than english? (I am using matplotlib.dates) 如何使用带有使用matplotlib的单个矢量或数组输入的函数来绘制表面? - How can I plot a surface using a function with a single vector or array input using matplotlib? 如何使用 matplotlib plot 0/1 数组 - How to plot an array of 0/1 using matplotlib 如何使用Matplotlib在python中定义和绘制10 * 10数组? - how can I define and plot an 10*10 array in python with Matplotlib? 我如何使用matplotlib用timedelta绘制图形 - how can i plot a graph with timedelta using matplotlib 如何使用 matplotlib 在 statsmodel 中绘制 Logit 的结果 - How can I plot the results of Logit in statsmodel using matplotlib 如何使用matplotlib在python中保存一个图? - How can I save a plot in python using matplotlib? 如何在matplotlib中使用一个数据框绘制两个图? - How can I plot two graphs using one dataframe in matplotlib? 我有一个值数组,如何使用 matplotlib 的 plot 值使其看起来像 25 秒的视频 - I have an array of values, how can I plot values using matplotlib so that it looks like a video of 25 seconds
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM