0
$\begingroup$

How can I plot circle plot with ListPlot function or how to organize data to produce circle plot from ListPlot function ?

If u do something like this

ListPlot[Tuples[{{0, 1, 2, 3, 4, 5}, {-3, 3}}]]

i get

{{0, -3}, {0, 3}, {1, -3}, {1, 3}, {2, -3}, {2, 3}, {3, -3}, {3, 
  3}, {4, -3}, {4, 3}, {5, -3}, {5, 3}}

function value in this example is constant, and we ll see two straight lines.

but, when i need to plot circle, i have two y points per x and they are changing,

so i want plot list plot, i must have data like this:

{{0, f1[0]}, {0, f2[0]}, {1, f1[1]}, {1, f2[1]}, {2, f1[2]}, {2, f2[2]}, {3, f1[3]}, {3,f2[3]}, {4, f1[4]}, {4, f2[4]}, {5, f1[5]}, {5, f2[5]}}

where f1 is y1 and f2 is y2 and

yn = {-Sqrt[R - x^2], Sqrt[R - x^2]}

or, i can make data like this

in = Function[x, {x, (-Sqrt[25 - #1^2]) &[x], (Sqrt[25 - #1^2]) &[x]}] /@ 
 Range[-5, 5, 1/2]
out = {{-5, 0, 0}, {-(9/2), -(Sqrt[19]/2), Sqrt[19]/2},.....

where we have {x1,y1,y2}, but List plot dosent work with this data

So, How can i plot this?

$\endgroup$
  • $\begingroup$ Are you aware of ListPolarPlot? If so, why do you want to use ListPlot. Also, instead of Pythagoras, you can easily generate x and y from the Cos and Sin of the angle. $\endgroup$ – Martin Ender Apr 22 '16 at 11:34
  • 1
    $\begingroup$ p.s. CirclePoints. $\endgroup$ – Kuba Apr 22 '16 at 12:13
  • $\begingroup$ Following up on @Kuba's comment, try this: ListPlot[CirclePoints[100], AspectRatio -> Automatic]. It's a pretty compact way of doing what you ask. Notice the AspectRatio directive in order to produce an undistorted circle. $\endgroup$ – MarcoB Apr 22 '16 at 14:48
4
$\begingroup$

Try this:

    ListPlot[Table[{Cos[a], Sin[a]}, {a, 0, 2 \[Pi], 0.05}], 
 AspectRatio -> 1]

with the effect of

enter image description here

Have fun!

$\endgroup$
  • $\begingroup$ Thanks, am soo bad at Table, can u tell me how to vary 'a' in ListPointPlot3D[ Table[{5 Cos[fi], 5 Sin[fi], a}, {fi, 0, 2 Pi, Pi/180}]] to produce cylindrical surface $\endgroup$ – Gelios Apr 22 '16 at 12:17
  • $\begingroup$ @Gelios Table takes more than one iterator as well. Try this for example: ListPointPlot3D[Flatten[Table[{5 Cos[fi], 5 Sin[fi], a}, {fi, 0, 2 Pi, Pi/180}, {a, -1, 1, 0.1}], 1]], which returns this plot. $\endgroup$ – MarcoB Apr 22 '16 at 14:46
  • $\begingroup$ I see, it works, but i concerned more about data representation, i'm trying threat coordinates line a сartesian product of set(str. line and circle produces cylindrical surf.). And If i use your answer i obtain just work solution with ListPointPlot3D, but if i try this ` MatrixForm@ Table[{5 Cos[fi], 5 Sin[fi], a}, {fi, 0, 2 Pi, Pi/180}, {a, -1, 1, 0.1}]` it dosent make clear sence, whereas ` MatrixForm@Table[{5 Cos[fi], 5 Sin[fi], a}, {fi, 0, 2 Pi, Pi/180}] ` is pretty good, but 'a' should changing after one cycle and i can achieve this using AppenTo and For, but It does not look good $\endgroup$ – Gelios Apr 22 '16 at 15:45
  • $\begingroup$ excuse me, all ok with your solution. $\endgroup$ – Gelios Apr 22 '16 at 18:55
  • $\begingroup$ @Gelios MatrixForm is for visualization only, not for further calculation or plotting. $\endgroup$ – Alexei Boulbitch Apr 23 '16 at 9:13
2
$\begingroup$

I guess, it will give you the circle: ListPlot[Table[{R Cos[fi],R Sin[fi]},{fi,0,2Pi,Pi/180}],AspectRatio->1]

$\endgroup$

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

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