[Tutor] Rearrange a list

EK Esawi ekesawi at yahoo.com
Fri May 1 18:20:24 EDT 2020


Thank you Peter, Mats and Alan. Allan’s answer is close.

 I am suing Matplotlib, to create a char, which I understand that Matplotlib is a 3rd party software and thus the question may not be suitable here. But here is a detailed description just in case it helps. I created a plot and I wanted to draw a set of straight lines between 2 sets of coordinate points. I wanted each line to not be connected with the line after it.  My solution is to go back and forth to avoid the diagonal line that connects the 2nd coordinate of the previous point and the 1st coordinate of the following one.

 Here is a little drawing if it helps: My solution is to start at 1 then move to 2, 4, 3, 5, 6 etc. If I don’t do this I get additional diagonal lines drown between 2 and 3 , 5 and 6, etc. Hope this helps. Alan’s solution produces extra points and misses ones.

Here is a set of points that I want to get (2,4),(4,3),(3,5),(5,6),(6,8),(8,7), (7,9), (9,10), (10,12), (12,11), etc

                              . 1
                         4 .____.2
                     3._________.5
                 6.____________.8



Thanks again
EK


More information about the Tutor mailing list