python27 matplotlib: first and last element connected

前端 未结 5 1704
野趣味
野趣味 2020-12-17 00:08

Hi I have found the same problem but without an answer: enter link description here

My problem is that I try to plot data with the matplotlib and it connects the fir

5条回答
  •  暖寄归人
    2020-12-17 00:58

    I had similar problem as you can see:

    BEFORE

    I just sorted x using this:

    x = sorted(x)
    

    And the line disappeared as you can see: (But the data is disturbed due to sorting).

    AFTER SORTING

    You must also make sure the respective y values should also be accordingly arranged for the sorted x. The final output is here:

    FIXED

提交回复
热议问题