【问题标题】:Plotting many lines in one figure in Python using two for loops在 Python 中使用两个 for 循环在一个图形中绘制多条线
【发布时间】:2019-11-07 14:48:46
【问题描述】:

在下面的代码中,我试图在一个图中绘制一些线。第二个循环给出一条线,第一个循环用不同的值重复该线,所以我们在一个图中有很多线。

问题是一旦画线,终点和起点就用直线相互连接。我无法理解问题所在。

while True:
        inp  = float(input("PLEASE ENTER VALUE): "))
        if inp==0:
            print('***')
            print('0 Is not acceptable')
            print('***')
        else:
            nu_list=[]
            Un_list=[]
            for tmp in range (2,6):
                for xx in range(1,819):
                         .... some lines of code
                    if inp<0:
                        if lim > 1:
                            pass
                        else:
                            nu_list.append(dfimppara.iloc[xx, 1] * 115)
                            ET_list.append(Un(xx, tmp))
                            plt.plot(nu_list, Un_list)
                    else: 
                        ...#some lines of code

plt.show()

【问题讨论】:

    标签: python matplotlib plot


    【解决方案1】:

    尝试在tmp for 循环中移动两个空列表。

    while True:
        inp  = float(input("PLEASE ENTER VALUE): "))
        if inp==0:
            print('***')
            print('0 Is not acceptable')
            print('***')
        else:
            for tmp in range (2,6):
                nu_list=[]
                Un_list=[]
                for xx in range(1,819):
                         .... some lines of code
    

    【讨论】:

      猜你喜欢
      • 2021-02-12
      • 1970-01-01
      • 2022-10-15
      • 1970-01-01
      • 2015-08-29
      • 2023-04-08
      • 2019-06-30
      • 1970-01-01
      • 2022-01-05
      相关资源
      最近更新 更多