1
$\begingroup$

I have that list of points with 4 coordinates.

sols = {{x1 -> -0.1465958058813781`, y1 -> -0.6972834336845714`, 
 x2 -> -0.6972834336845712`, y2 -> -0.14659580588137808`}, {x1 -> 0.6972834336845714`, 
 y1 -> -0.14659580588137813`, x2 -> 0.14659580588137816`, 
 y2 -> -0.6972834336845712`}, {x1 -> 0.14659580588137816`, 
 y1 -> 0.6972834336845714`, x2 -> 0.6972834336845712`, 
 y2 -> 0.14659580588137808`}}

I would like to plot the dots, with the coordinates $x_1 , y_1$ in one plot, and $x_2,y_2$ in another plot. How can I do it ?

Thx in advance

$\endgroup$

2 Answers 2

1
$\begingroup$
ListPlot[List /@ #, Frame -> True, Axes -> False, 
   BaseStyle -> PointSize[Large], ImageSize -> 300] & /@ 
 Transpose[{{x1, y1}, {x2, y2}} /. sols]

enter image description here

$\endgroup$
1
$\begingroup$
sols1 = {x1, y1} /. sols;
sols2 = {x2, y2} /. sols;

ListPlot[sols1]
ListPlot[sols2]

or a one line solution for fun:

ListPlot /@ (sols[[;; , #, 2]] & /@ {{1, 2}, {3, 4}})

EDIT: To plot each point of a different colour and match the colours of the two plots, here's the fastest solution:

sols1 = {{x1, y1}} /. sols;
sols2 = {{x2, y2}} /. sols;

ListPlot[sols1]
ListPlot[sols2]

If you want to choose a color scheme for your points (e.g. AvocadoColours), see code below:

colours = ColorData["AvocadoColors"][[4]] /@ Range[0, 1, 1/(Length@sols1 - 1)]

ListPlot[sols1, PlotStyle -> colours]
ListPlot[sols2, PlotStyle -> colours]
$\endgroup$
2
  • $\begingroup$ Thx ! Is there a way to plot each point with a different color, so that it is easy to connect each $x_1,y_1$ to its $x_2,y_2$ ? $\endgroup$
    – J.A
    Jul 3, 2018 at 14:46
  • 1
    $\begingroup$ Sure, see the edit to my answer. $\endgroup$
    – Fraccalo
    Jul 3, 2018 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.