0

Is there a way to show the numbers that correspond to a point on a circle? I read up on the text(xy) function but it is for scatter plots which this is not. The scripts is as follows and the image attached shows what the result is. I would like to identify the point in the plots. Any help rendered is appreciated! Thanks.

library (circular)
df<- read.csv("Direction.csv", header = TRUE)
df1 <- df [ which(df$Month==1 & df$Day>0 & df$Day <32) ,]
df2 <- df1[c(-1,-2,-3)]
df3<- lapply(df2, function(df2) circular(df2, units='degrees', template='geographics'))
dens<- lapply(df3, density.circular, bw =5)
par(mfrow=c(5,4), oma=c(2,1.3,2,2), mar=c(1.5,2,2,1), tcl=-0.2, mgp=c(0,1,0))
titles <- c("1000mb", "925mb", "850mb", "700mb", "600mb", "500mb", "400mb", "300mb", 
            "250mb", "200mb", "150mb", "100mb","70mb", "50mb", "30mb", "20mb", "10mb")
for(i in 1:17){
  plot(mean(df3[[1]]), main = titles[1],) 
  print(mean(df3[[1]]))
  print(var(df3[[1]]))
  print(summary(df3[[1]]))
}
dput(df3[1])
structure(list(X1000mb = structure(c(86L, 130L, 75L, 59L, 56L, 
69L, 139L, 358L, 98L, 175L, 322L, 17L, 336L, 46L, 137L, 1L, 2L, 
102L, 225L, 121L, 179L, 291L, 325L, 317L, 321L, 349L, 28L, 38L, 
36L, 117L, 144L, 73L, 121L, 135L, 131L, 127L, 139L, 167L, 298L, 
213L, 37L, 33L, 71L, 120L, 156L, 14L, 51L, 92L, 168L, 332L, 24L, 
71L, 128L, 98L, 104L, 86L, 155L, 5L, 281L, 342L, 356L, 346L, 
210L, 186L, 199L, 133L, 191L, 282L, 139L, 168L, 158L, 154L, 117L, 
149L, 162L, 157L, 192L, 175L, 197L, 171L, 184L, 305L, 70L, 169L, 
207L, 8L, 72L, 134L, 160L, 135L, 154L, 149L, 161L, 182L, 259L, 
173L, 205L, 331L, 112L, 26L, 129L, 137L, 120L, 136L, 156L, 327L, 
332L, 349L, 16L, 28L, 42L, 352L, 94L, 149L, 153L, 183L, 183L, 
196L, 170L, 164L, 212L, 169L, 180L, 206L, 81L, 135L, 145L, 148L, 
172L, 174L, 160L, 188L, 193L, 197L, 247L, 68L, 181L, 177L, 219L, 
204L, 86L, 333L, 354L, 132L, 0L, 35L, 27L, 38L, 77L, 123L, 174L, 
172L, 191L, 312L, 307L, 29L, 161L, 62L, 104L, 240L, 300L, 292L, 
194L, 202L, 274L, 349L, 26L, 198L, 294L, 185L, 178L, 324L, 28L, 
36L, 93L, 115L, 280L, 24L, 353L, 348L, 68L, 24L, 357L, 17L, 47L, 
45L, 238L, 333L, 342L, 111L, 233L, 183L, 193L, 212L, 188L, 164L, 
142L, 158L, 179L, 300L, 336L, 297L, 346L, 17L, 149L, 115L, 8L, 
358L, 341L, 22L, 142L, 283L, 349L, 273L, 271L, 224L, 313L, 62L, 
100L, 137L, 158L, 235L, 155L, 184L, 132L, 153L, 206L, 182L, 187L, 
238L, 275L, 292L, 1L, 36L, 148L, 334L, 30L, 58L, 356L, 6L, 345L, 
91L, 157L, 332L, 327L, 11L, 170L, 169L, 120L, 158L, 160L, 177L, 
168L, 300L, 295L, 7L, 75L, 172L, 328L, 3L, 63L, 348L, 34L, 185L, 
347L, 66L, 105L, 130L, 151L, 83L, 120L, 154L, 172L, 152L, 174L, 
174L, 159L, 147L, 173L, 212L, 327L, 55L, 203L, 192L, 95L, 139L, 
200L, 227L, 209L, 262L, 129L, 151L, 200L, 133L, 190L, 112L, 85L, 
184L, 185L, 186L, 256L, 28L, 157L, 54L, 55L, 88L, 315L, 27L, 
53L, 126L, 179L, 161L, 163L, 168L, 280L, 336L, 89L, 175L, 253L, 
357L, 250L, 36L, 62L, 103L, 1L, 5L, 55L, 97L, 114L, 143L, 156L, 
156L, 178L, 183L, 191L, 285L, 4L, 16L, 69L, 340L, 63L, 131L, 
128L, 137L, 137L, 253L, 213L, 165L, 166L, 166L, 171L, 193L, 186L, 
180L, 194L, 255L, 294L, 60L, 175L, 123L, 136L, 147L, 144L, 146L, 
135L, 157L, 228L, 177L, 165L, 168L, 176L, 182L, 352L, 23L, 260L, 
298L, 283L, 152L, 151L, 180L, 170L, 2L, 60L, 121L, 110L, 153L, 
174L, 204L, 312L, 153L, 250L, 223L, 244L, 345L, 225L, 233L, 289L, 
212L, 190L, 285L, 226L, 136L, 111L, 179L, 200L, 274L, 2L, 351L, 
10L, 12L, 13L, 340L, 336L, 331L, 258L, 36L, 95L, 117L, 149L, 
151L, 155L, 135L, 187L, 191L, 195L, 15L, 103L, 161L, 194L, 186L, 
167L, 90L, 174L, 205L, 173L, 208L, 197L, 217L, 246L, 151L, 161L, 
119L, 128L, 159L, 232L, 198L, 227L, 175L, 213L, 220L, 226L, 171L, 
244L, 203L, 167L, 185L, 156L, 182L, 157L, 154L, 144L, 146L, 174L, 
196L, 141L, 348L, 22L, 63L, 125L, 163L, 32L, 331L, 19L, 72L, 
85L, 186L, 297L, 353L, 32L, 242L, 240L, 191L, 200L, 192L, 208L, 
256L, 193L, 243L, 3L, 18L, 293L, 357L, 233L, 169L, 160L, 189L, 
310L, 305L, 288L, 201L, 334L, 56L, 274L, 269L, 303L, 237L, 224L, 
230L, 170L, 192L, 135L, 194L, 132L, 122L, 149L, 171L, 199L, 217L, 
133L, 172L, 195L, 329L, 11L, 48L, 120L, 158L, 198L, 23L, 109L, 
154L, 145L, 86L, 41L, 156L, 186L, 222L, 150L, 163L, 19L, 278L, 
325L, 352L, 5L, 72L, 136L, 123L, 149L, 154L, 132L, 155L, 233L, 
187L, 168L, 9L, 41L, 262L, 4L, 40L, 154L, 157L, 233L, 97L, 162L, 
171L, 171L, 181L, 355L, 35L, 103L, 214L, 355L, 335L, 345L, 13L, 
331L, 347L, 323L, 294L, 234L, 295L, 190L, 151L, 182L, 231L, 268L, 
286L, 20L, 11L, 144L, 181L, 149L, 160L, 180L, 343L, 65L, 130L, 
108L, 166L, 164L, 182L, 160L, 174L, 101L, 27L, 62L, 110L, 76L, 
25L, 150L, 173L, 169L, 183L, 181L, 189L, 167L, 232L, 345L, 154L, 
216L, 195L, 212L, 242L, 289L, 252L, 111L, 148L, 161L, 159L, 153L, 
162L, 139L, 158L, 150L, 164L, 198L, 14L, 141L, 156L, 288L, 355L, 
36L, 73L, 208L, 215L, 323L, 135L, 188L, 289L, 232L, 227L, 317L, 
222L, 192L, 76L, 40L, 172L, 157L, 142L, 216L, 223L, 163L, 237L, 
344L, 30L, 126L, 143L, 162L, 162L, 104L, 103L, 123L, 110L, 140L, 
146L, 149L, 139L, 161L, 194L, 187L, 283L, 13L, 16L, 185L, 177L, 
200L, 155L, 152L, 169L, 238L, 282L, 161L, 185L, 224L, 198L, 159L, 
208L, 309L, 179L, 182L, 244L, 290L, 217L, 236L, 20L, 61L, 130L, 
162L, 262L, 245L, 206L, 225L, 193L, 331L, 34L, 133L, 216L, 277L, 
343L, 300L, 342L, 15L, 50L, 307L, 314L, 5L, 24L, 19L, 86L, 120L, 
356L, 34L, 19L, 346L, 359L, 25L, 45L, 97L, 151L, 67L, 100L, 23L, 
66L, 9L, 223L, 121L, 164L, 175L, 174L, 217L, 227L, 241L, 184L, 
265L, 196L, 215L, 178L, 326L, 102L, 339L, 21L, 43L, 19L, 65L, 
289L, 288L, 94L, 97L, 132L, 123L, 141L, 141L, 282L, 220L, 281L, 
202L, 252L, 225L, 350L, 77L, 199L, 274L, 209L, 229L, 5L, 67L, 
19L, 28L, 56L, 89L, 71L, 68L, 126L, 120L, 124L, 112L, 83L, 171L, 
25L, 306L, 305L, 338L, 3L, 319L, 12L, 70L, 19L, 185L, 199L, 88L, 
140L, 176L, 207L, 149L, 155L, 162L, 152L, 164L, 178L, 201L, 214L, 
169L, 175L, 180L, 168L, 183L, 163L, 186L, 257L, 223L, 166L, 157L, 
133L, 24L, 115L, 162L, 173L, 245L, 147L, 105L, 81L, 75L, 75L, 
47L, 27L, 15L, 347L, 21L, 116L, 160L, 178L, 193L, 51L, 232L, 
295L, 358L, 311L, 16L, 17L, 7L, 47L, 345L, 4L, 36L, 118L, 209L, 
173L, 231L, 8L, 90L, 156L, 237L, 163L, 343L, 350L, 354L, 36L, 
62L, 45L, 43L, 95L, 113L, 164L, 317L, 315L, 168L, 188L, 190L, 
168L, 227L, 185L, 142L, 249L, 200L, 228L, 7L, 50L, 95L, 265L, 
10L, 75L, 63L, 151L, 124L, 146L, 35L, 303L, 331L, 218L, 303L, 
312L, 341L, 33L, 36L, 9L, 74L, 85L, 105L, 99L, 101L, 91L, 130L, 
152L, 14L, 211L, 271L, 319L, 315L, 309L, 358L, 31L), circularp = structure(list(
    type = "angles", units = "degrees", template = "geographics", 
    modulo = "asis", zero = 1.5707963267949, rotation = "clock"), .Names = c("type", 
"units", "template", "modulo", "zero", "rotation")), class = c("circular", 
"integer"))), .Names = "X1000mb")

enter image description here

Gunnerfan
  • 123
  • 3
  • 10
  • 4
    Please make your example complete - right now, it doesn't plot your circles. Include the output of `dput(df3)` in your code. Even better, cut your example down to a single picture to make your example [minimal](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – Stephan Kolassa Dec 18 '14 at 15:34
  • @StephanKolassa you asked for it and it shall be put in. It is very long and a list so here you go! – Gunnerfan Dec 18 '14 at 16:27
  • @Gunnerfan, Please show the code you used to produce the plot in your post, given the `dput`ed data. – Henrik Dec 18 '14 at 16:47
  • @Henrik...it is edited to show that – Gunnerfan Dec 18 '14 at 17:08
  • @Gunnerfan, The data preparation steps are not very relevant. Again, please show the _plot command_ which can be used **on the `dput`ed data**. – Henrik Dec 18 '14 at 17:25
  • @Henrik The _plot command_ used are included unless I am not understanding your statement. `plot(mean(df3[[1]]), main = titles[1],)` is the command. What _plot command_ are you asking for? – Gunnerfan Dec 18 '14 at 17:32
  • `plot(mean(thenameofyourdputeddata), main = titles[1])`; `Error in plot.window(...) : need finite 'ylim' values` `In addition: Warning messages:` – Henrik Dec 18 '14 at 17:35
  • Sorry, I give up. For next time: please read these links on **minimal, self contained examples**: [**here**](http://stackoverflow.com/help/mcve), [**here**](http://www.sscce.org/), [**here**](http://adv-r.had.co.nz/Reproducibility.html), and [**here**](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610). – Henrik Dec 18 '14 at 17:36
  • @Henrik The name of the dputed data is df3[1] which is included there. Thanks for the time taken, it is still appreciated. Your questions asked is not straightforward. The answer below is actually related to the question asked which has to do with labelling plots. – Gunnerfan Dec 18 '14 at 17:45

1 Answers1

2

It doesn't matter that it's not strictly a "scatterplot" . Now that you've set up an array of subplots, you can cycle thru them again, but this time using text() to place data at the desired location within each subplot. Roughly,

for (i in 1:17 )  text(x_loc[i],y_loc[i], some_text_vector[i])

Where you've "preloaded" the text strings and locations.

Carl Witthoft
  • 20,573
  • 9
  • 43
  • 73
  • going by your statement, I tried this `for (i in 1:17 ) text(df3[i],df3[i])`but I get `Error in xy.coords(x, y, recycle = TRUE) : (list) object cannot be coerced to type 'double'` – Gunnerfan Dec 18 '14 at 16:33
  • Then fix your inputs so you're not feeding a `list` object where numbers are needed. `text(df3[i])` most likely is not doing what you think it is. – Carl Witthoft Dec 18 '14 at 17:52