Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Line between first and last point

I'm drawing a chart in Matplotlib , using the plot(x, y) command where x and y are arrays. In the resulting chart I have the first and last point connected by a line. How to avoid the first and last point to be connected ?

like image 457
jerome Avatar asked Oct 23 '13 11:10

jerome


1 Answers

I had similar problem as you can see:

BEFORE enter image description here

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 enter image description here

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

FIXED enter image description here

like image 141
Trees Avatar answered Oct 18 '22 03:10

Trees