回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我首先编写了一个函数,它包含18个参数,并将它们转换成6个不同的列表。代码如下:</p>
<pre><code>def list_maker(val1,val2,val3,val4,val5,val6,val7,val8,val9,por1,por2,por3,hth1,hth2,hth3,sat1,sat2,sat3):
#Make the voip list
list1 = [val1,val2,val3]
list2 = [val4,val5,val6]
list3 = [val7,val8,val9]
#Make the variable list
list_por = [por1,por2,por3]
list_hth = [hth1,hth2,hth3]
list_sat = [sat1,sat2,sat3]
return list1,list2,list3,list_por,list_hth,list_sat
</code></pre>
<p>这部分工作得很好(我会让它看起来更好,一旦它真的工作)。
现在,我的想法是使用这个函数作为下面另一个函数的输入来创建绘图:</p>
<pre><code>def graph_maker(listx1,listx2,listx3,list1,list2,list3):
#plot the saturation graph
por_plot = plt.plot(listx1,list1)
por_plot.ylabel('VOIP')
por_plot.xlabel('Porosity')
por_plot.show()
#plot the heigth graph
hth_plot = plt.plot(listx2,list2)
hth_plot.ylabel('VOIP')
hth_plot.xlabel('Height')
hth_plot.show()
#plot the saturation graph
sat_plot = plt.plot(listx3,list3)
sat_plot.ylabel('VOIP')
sat_plot.xlabel('Saturation')
sat_plot.show()
</code></pre>
<p>所以我用以下两行代码运行代码:</p>
<pre><code>list_maker(voip1,voip2,voip3,voip4,voip5,voip6,voip7,voip8,voip9,0.3,0.2,0.15,100,150,200,0.8,0.6,0.5)
graph_maker(list_maker)
</code></pre>
<p>我得到的错误是:</p>
<blockquote>
<p>graph_maker() missing 5 required positional arguments: 'listx2',
'listx3', 'list1', 'list2', and 'list3'</p>
</blockquote>
<p>据我所知,似乎list\u maker()实际上只返回一个列表,显然graph\u maker函数需要6个参数。有什么想法吗</p>
<p>谢谢你的帮助</p>