3
$\begingroup$

I've got a list of data of the form {{0,x0},...,{359,x359}}, which represents some experimental results given in polar coordinates with fixed radius. How to plot this data on a circle , i.e. it should be something like ListPlot but ends should be glued together.

$\endgroup$
  • $\begingroup$ To reduce confusion, I recommend that you remove the underscores and write x0 and x359 or x[0] and x[359] instead. $\endgroup$ – JungHwan Min Jan 5 '16 at 16:15
  • 6
    $\begingroup$ ListPolarPlot may be what you are looking for. $\endgroup$ – JungHwan Min Jan 5 '16 at 16:17
5
$\begingroup$

ListPolarPlot does what you want.

Just for fun, here is a simple alternative implementation using Graphics primitives, and drawing lines instead of just the points:

Options[circleListPlot] = {circleRadius -> .01, maxOutwardLength -> 0,
    withLines -> True};
circleListPlot[data_, OptionsPattern[]] := Module[{scaledData},
  If[OptionValue@maxOutwardLength == 0,
   scaledData = data,
   scaledData = {
       #[[1]],
       OptionValue@circleRadius + (#[[2]] - Min@data[[All, 2]])/(
         Max@data[[All, 2]] - Min@data[[All, 2]])
          OptionValue@maxOutwardLength
       } & /@ data
   ];
  Graphics[
   {
    Red, Thick, Circle[{0, 0}, OptionValue@circleRadius],
    Darker@Green, Thin,
    Line[
       Function[pointOnUnitaryCircle,
         {
          OptionValue@circleRadius pointOnUnitaryCircle,
          #[[2]] pointOnUnitaryCircle
          }
         ]@{Cos[#[[1]] Degree], Sin[#[[1]] Degree]}
       ] & /@ scaledData
    },
   Axes -> True
   ]
  ]

Which you can call like this:

data = MapIndexed[{First@#2, #1} &, RandomReal[{0, 1}, 360]];
circleListPlot[data, circleRadius -> 0.2, maxOutwardLength -> 2]

enter image description here

Or, taking from the first example in the documentation of ListPolarPlot:

circleListPlot[Table[{n, Sqrt[n]}, {n, 360}], circleRadius -> 1]

enter image description here

$\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.