1
$\begingroup$

I am trying to get direction data into an histogram a circular one. Something like this:

    data={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {351, 341, 343, 298, 270, 417, 600, 0, 335, 248, 312, 342}, {336, 346, 352, 323, 323, 448, 704, 0, 
  319, 302, 347, 369}, {211, 247, 284, 397, 397, 344, 608, 0, 304, 
  258, 260, 222}, {130, 196, 268, 324, 421, 243, 616, 0, 268, 274, 
  261, 162}, {114, 157, 229, 213, 290, 181, 532, 0, 241, 226, 225, 
  173}, {127, 178, 258, 183, 191, 218, 628, 0, 244, 281, 259, 
  150}, {199, 266, 299, 237, 227, 342, 866, 0, 347, 314, 329, 
  166}, {268, 313, 357, 312, 430, 543, 1488, 0, 606, 481, 459, 
  214}, {380, 373, 453, 356, 546, 662, 1606, 0, 803, 732, 421, 
  229}, {435, 427, 563, 435, 622, 697, 1442, 0, 668, 745, 485, 
  346}, {340, 413, 533, 520, 676, 549, 1050, 0, 495, 556, 461, 
  319}, {483, 498, 541, 600, 726, 468, 904, 0, 415, 529, 503, 
  495}, {1036, 590, 628, 635, 541, 322, 618, 0, 358, 639, 681, 
  1084}, {1367, 738, 645, 759, 394, 329, 584, 0, 355, 484, 627, 
  1322}, {560, 570, 490, 459, 306, 298, 478, 0, 322, 324, 364, 503}}

I already made a histogram with sectors divided by 360 degrees, so each repetition of the values will make a sector bigger adding each repetition of the value on degrees:

ljN1 = Range[1] + 5
ljN2 = Range[1] + 354
ljNEN1 = Range[Part[Data, 2, 1]]*0 + 16
ljNEN2 = Range[Part[Data, 2, 1]]*0 + 28
ljNE1 = Range[Part[Data, 3, 1]]*0 + 39
ljNE2 = Range[Part[Data, 3, 1]]*0 + 50
ljNEE1 = Range[Part[Data, 4, 1]]*0 + 61
ljNEE2 = Range[Part[Data, 4, 1]]*0 + 73
ljE1 = Range[Part[Data, 5, 1]]*0 + 84
ljE2 = Range[Part[Data, 5, 1]]*0 + 95
ljSEE1 = Range[Part[Data, 6, 1]]*0 + 106
ljSEE2 = Range[Part[Data, 6, 1]]*0 + 118
ljSE1 = Range[Part[Data, 7, 1]]*0 + 129
ljSE2 = Range[Part[Data, 7, 1]]*0 + 140
ljSES1 = Range[Part[Data, 8, 1]]*0 + 151
ljSES2 = Range[Part[Data, 8, 1]]*0 + 163
ljS1 = Range[Part[Data, 9, 1]]*0 + 174
ljS2 = Range[Part[Data, 9, 1]]*0 + 185
ljSWS1 = Range[Part[Data, 10, 1]]*0 + 196
ljSWS2 = Range[Part[Data, 10, 1]]*0 + 208
ljSW1 = Range[Part[Data, 11, 1]]*0 + 219
ljSW2 = Range[Part[Data, 11, 1]]*0 + 230
ljSWW1 = Range[Part[Data, 12, 1]]*0 + 241
ljSWW2 = Range[Part[Data, 12, 1]]*0 + 253
ljW1 = Range[Part[Data, 13, 1]]*0 + 264
ljW2 = Range[Part[Data, 13, 1]]*0 + 275
ljNWW1 = Range[Part[Data, 14, 1]]*0 + 286
ljNWW2 = Range[Part[Data, 14, 1]]*0 + 298
ljNW1 = Range[Part[Data, 15, 1]]*0 + 309
ljNW2 = Range[Part[Data, 15, 1]]*0 + 320
ljNWN1 = Range[Part[Data, 16, 1]]*0 + 331
ljNWN2 = Range[Part[Data, 16, 1]]*0 + 343

Jan2018 = 
 Join[ljN1, ljN2, ljNEN1, ljNEN2, ljNE1, ljNE2, ljNEE1, ljNEE2, ljE1, 
  ljE2, ljSEE1, ljSEE2, ljSE1, ljSE2, ljSES1, ljSES2, ljS1, ljS2, 
  ljSWS1, ljSWS2, ljSW1, ljSW2, ljSWW1, ljSWW2, ljW1, ljW2, ljNWW1, 
  ljNWW2, ljNW1, ljNW2, ljNWN1, ljNWN2]

f[dat_, nSectors_, polarGridLinesQ_] := 
 Module[{binwidth = 360/nSectors}, 
  SectorChart[
   Thread[{ConstantArray[1, 360/binwidth], 
     BinCounts[Jan2018, binwidth]}], 
   PolarAxes -> If[polarGridLinesQ, {True, True}, {False, True}], 
   PolarTicks -> {If[polarGridLinesQ, "Degrees", None], Automatic}, 
   PolarGridLines -> 
    If[polarGridLinesQ, {Table[
       2 Pi k/nSectors + Pi/4, {k, 1, nSectors}], Automatic}, {None, 
      None}], SectorOrigin -> {Pi/2, "Clockwise"}]]

Like this:

enter image description here

However now I want to link the repetition of the values of each sector to another series of values, is like lets say that the values that add to the 180 degrees have each one an associated value so I can say that I have a 130 repetitions on the South sector but also that sector has a value of 23. Same happens with each sector so the size tells me the number of repetitions, the position tells me the direction of the value, now I want to know if it's possible to link a gradient of colors depending on the value for each position.

As an example: the sector between 255 and 285 degrees is bigger than the sector between 285 to 300 degrees. Cause it has more repetitions, but the sector between 285 to 300 degrees has a value of 18 and the sector between 255 to 285 has a value of 10.

Then the shade of colors should tell me that the value of 285 to 300 is bigger than 255 to 285.

Kind Regards and sorry the question was badly explained before :3.

$\endgroup$
2
  • $\begingroup$ Please share the code that you already have that generated those plots. $\endgroup$
    – MarcoB
    Nov 22, 2019 at 15:08
  • $\begingroup$ Done it, Marco sorry for that I just finished part of the code. I took that image from an example. Now is the code from my stuff :3. Cheers!. $\endgroup$ Nov 22, 2019 at 20:31

1 Answer 1

3
$\begingroup$
data = {8, 9, 13, 13, 14, 18, 22, 27, 30, 34, 38, 38, 40, 44, 45, 47, 48, 48, 48, 48, 50, 
  53, 56, 57, 58, 58, 61, 63};

SeedRandom[1]
values = RandomInteger[{1, 10}, Length@data]

{2, 5, 1, 8, 1, 1, 9, 7, 1, 5, 2, 9, 6, 2, 2, 2, 4, 3, 2, 7, 1, 3, 7, 5, 6, 5, 4, 1}

Construct a data set of pairs from data and values:

pairs = Transpose[{data, values}];

Sum the radii associated with each angle using GroupBy :

data2 = List @@@ Normal @ GroupBy[pairs, First -> Last, Total]

{{8, 2}, {9, 5}, {13, 9}, {14, 1}, {18, 1}, {22, 9}, {27, 7}, {30, 1}, {34, 5}, {38, 11}, {40, 6}, {44, 2}, {45, 2}, {47, 2}, {48, 16}, {50, 1}, {53, 3}, {56, 7}, {57, 5}, {58, 11}, {61, 4}, {63, 1}}

Use data2 with [SectorChart`](https://reference.wolfram.com/language/ref/SectorChart.html):

SectorChart[data2, 
 PolarAxes -> True, 
 PolarTicks -> {"Degrees", Automatic}, 
 PolarGridLines -> Automatic, 
 SectorOrigin -> {{Pi/2, "Clockwise"}, 0}]

enter image description here

SectorChart[data2, SectorOrigin -> {{Pi/2, "Clockwise"}, 0}, 
 PolarAxes -> {False, True}]

enter image description here

$\endgroup$
1
  • $\begingroup$ Sorry for taking this long, I was wrong on my explanation. Now is a bit better but your answer also helped me a lot :). $\endgroup$ Nov 25, 2019 at 22:44

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.