plot-to-file-example.nlogo 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. ;; Plot Example of R-extension
  2. ;;
  3. ;;
  4. ;; by Jan C. Thiele
  5. ;; University of Goettingen, Germany
  6. ;; Department Ecoinformatics, Biometrics and Forest Growth
  7. ;; Buesgenweg 4
  8. ;; 37077 Goettingen
  9. ;; Germany
  10. ;;
  11. ;; Contact: jthiele@gwdg.de
  12. ;;
  13. ;; Copyright: 2011, J.C. Thiele
  14. extensions [r]
  15. to test-plot
  16. clear-all
  17. crt 10
  18. [
  19. set xcor random-xcor
  20. set ycor random-ycor
  21. ]
  22. (r:putagent "agentlist" turtles "who" "xcor" "ycor")
  23. print "create a plot into file..."
  24. ;; create a pdf with the plot
  25. let evalstring (word "pdf('" plotfile ".pdf')" )
  26. show evalstring
  27. r:eval evalstring
  28. r:eval "plot(agentlist$xcor,agentlist$ycor)"
  29. r:eval "dev.off()"
  30. ;; create a jpeg with the plot
  31. set evalstring (word "jpeg('" plotfile ".jpeg')" )
  32. show evalstring
  33. r:eval evalstring
  34. r:eval "plot(agentlist$xcor,agentlist$ycor)"
  35. r:eval "dev.off()"
  36. end
  37. @#$#@#$#@
  38. GRAPHICS-WINDOW
  39. 230
  40. 10
  41. 667
  42. 448
  43. -1
  44. -1
  45. 13.0
  46. 1
  47. 10
  48. 1
  49. 1
  50. 1
  51. 0
  52. 1
  53. 1
  54. 1
  55. -16
  56. 16
  57. -16
  58. 16
  59. 0
  60. 0
  61. 1
  62. ticks
  63. 30.0
  64. INPUTBOX
  65. 8
  66. 74
  67. 198
  68. 134
  69. plotfile
  70. plot-filename
  71. 1
  72. 0
  73. String
  74. BUTTON
  75. 4
  76. 163
  77. 83
  78. 196
  79. NIL
  80. test-plot
  81. NIL
  82. 1
  83. T
  84. OBSERVER
  85. NIL
  86. NIL
  87. NIL
  88. NIL
  89. 1
  90. TEXTBOX
  91. 7
  92. 137
  93. 222
  94. 165
  95. If editing plotfile, don't use backslashes
  96. 11
  97. 0.0
  98. 1
  99. BUTTON
  100. 9
  101. 30
  102. 199
  103. 63
  104. Choose file
  105. set plotfile user-new-file
  106. NIL
  107. 1
  108. T
  109. OBSERVER
  110. NIL
  111. NIL
  112. NIL
  113. NIL
  114. 1
  115. @#$#@#$#@
  116. ## WHAT IS IT?
  117. This section could give a general understanding of what the model is trying to show or explain.
  118. ## HOW IT WORKS
  119. This section could explain what rules the agents use to create the overall behavior of the model.
  120. ## HOW TO USE IT
  121. This section could explain how to use the model, including a description of each of the items in the interface tab.
  122. ## THINGS TO NOTICE
  123. This section could give some ideas of things for the user to notice while running the model.
  124. ## THINGS TO TRY
  125. This section could give some ideas of things for the user to try to do (move sliders, switches, etc.) with the model.
  126. ## EXTENDING THE MODEL
  127. This section could give some ideas of things to add or change in the procedures tab to make the model more complicated, detailed, accurate, etc.
  128. ## NETLOGO FEATURES
  129. This section could point out any especially interesting or unusual features of NetLogo that the model makes use of, particularly in the Procedures tab. It might also point out places where workarounds were needed because of missing features.
  130. ## RELATED MODELS
  131. This section could give the names of models in the NetLogo Models Library or elsewhere which are of related interest.
  132. ## CREDITS AND REFERENCES
  133. This section could contain a reference to the model's URL on the web if it has one, as well as any other necessary credits or references.
  134. @#$#@#$#@
  135. default
  136. true
  137. 0
  138. Polygon -7500403 true true 150 5 40 250 150 205 260 250
  139. airplane
  140. true
  141. 0
  142. Polygon -7500403 true true 150 0 135 15 120 60 120 105 15 165 15 195 120 180 135 240 105 270 120 285 150 270 180 285 210 270 165 240 180 180 285 195 285 165 180 105 180 60 165 15
  143. arrow
  144. true
  145. 0
  146. Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150
  147. box
  148. false
  149. 0
  150. Polygon -7500403 true true 150 285 285 225 285 75 150 135
  151. Polygon -7500403 true true 150 135 15 75 150 15 285 75
  152. Polygon -7500403 true true 15 75 15 225 150 285 150 135
  153. Line -16777216 false 150 285 150 135
  154. Line -16777216 false 150 135 15 75
  155. Line -16777216 false 150 135 285 75
  156. bug
  157. true
  158. 0
  159. Circle -7500403 true true 96 182 108
  160. Circle -7500403 true true 110 127 80
  161. Circle -7500403 true true 110 75 80
  162. Line -7500403 true 150 100 80 30
  163. Line -7500403 true 150 100 220 30
  164. butterfly
  165. true
  166. 0
  167. Polygon -7500403 true true 150 165 209 199 225 225 225 255 195 270 165 255 150 240
  168. Polygon -7500403 true true 150 165 89 198 75 225 75 255 105 270 135 255 150 240
  169. Polygon -7500403 true true 139 148 100 105 55 90 25 90 10 105 10 135 25 180 40 195 85 194 139 163
  170. Polygon -7500403 true true 162 150 200 105 245 90 275 90 290 105 290 135 275 180 260 195 215 195 162 165
  171. Polygon -16777216 true false 150 255 135 225 120 150 135 120 150 105 165 120 180 150 165 225
  172. Circle -16777216 true false 135 90 30
  173. Line -16777216 false 150 105 195 60
  174. Line -16777216 false 150 105 105 60
  175. car
  176. false
  177. 0
  178. Polygon -7500403 true true 300 180 279 164 261 144 240 135 226 132 213 106 203 84 185 63 159 50 135 50 75 60 0 150 0 165 0 225 300 225 300 180
  179. Circle -16777216 true false 180 180 90
  180. Circle -16777216 true false 30 180 90
  181. Polygon -16777216 true false 162 80 132 78 134 135 209 135 194 105 189 96 180 89
  182. Circle -7500403 true true 47 195 58
  183. Circle -7500403 true true 195 195 58
  184. circle
  185. false
  186. 0
  187. Circle -7500403 true true 0 0 300
  188. circle 2
  189. false
  190. 0
  191. Circle -7500403 true true 0 0 300
  192. Circle -16777216 true false 30 30 240
  193. cow
  194. false
  195. 0
  196. Polygon -7500403 true true 200 193 197 249 179 249 177 196 166 187 140 189 93 191 78 179 72 211 49 209 48 181 37 149 25 120 25 89 45 72 103 84 179 75 198 76 252 64 272 81 293 103 285 121 255 121 242 118 224 167
  197. Polygon -7500403 true true 73 210 86 251 62 249 48 208
  198. Polygon -7500403 true true 25 114 16 195 9 204 23 213 25 200 39 123
  199. cylinder
  200. false
  201. 0
  202. Circle -7500403 true true 0 0 300
  203. dot
  204. false
  205. 0
  206. Circle -7500403 true true 90 90 120
  207. face happy
  208. false
  209. 0
  210. Circle -7500403 true true 8 8 285
  211. Circle -16777216 true false 60 75 60
  212. Circle -16777216 true false 180 75 60
  213. Polygon -16777216 true false 150 255 90 239 62 213 47 191 67 179 90 203 109 218 150 225 192 218 210 203 227 181 251 194 236 217 212 240
  214. face neutral
  215. false
  216. 0
  217. Circle -7500403 true true 8 7 285
  218. Circle -16777216 true false 60 75 60
  219. Circle -16777216 true false 180 75 60
  220. Rectangle -16777216 true false 60 195 240 225
  221. face sad
  222. false
  223. 0
  224. Circle -7500403 true true 8 8 285
  225. Circle -16777216 true false 60 75 60
  226. Circle -16777216 true false 180 75 60
  227. Polygon -16777216 true false 150 168 90 184 62 210 47 232 67 244 90 220 109 205 150 198 192 205 210 220 227 242 251 229 236 206 212 183
  228. fish
  229. false
  230. 0
  231. Polygon -1 true false 44 131 21 87 15 86 0 120 15 150 0 180 13 214 20 212 45 166
  232. Polygon -1 true false 135 195 119 235 95 218 76 210 46 204 60 165
  233. Polygon -1 true false 75 45 83 77 71 103 86 114 166 78 135 60
  234. Polygon -7500403 true true 30 136 151 77 226 81 280 119 292 146 292 160 287 170 270 195 195 210 151 212 30 166
  235. Circle -16777216 true false 215 106 30
  236. flag
  237. false
  238. 0
  239. Rectangle -7500403 true true 60 15 75 300
  240. Polygon -7500403 true true 90 150 270 90 90 30
  241. Line -7500403 true 75 135 90 135
  242. Line -7500403 true 75 45 90 45
  243. flower
  244. false
  245. 0
  246. Polygon -10899396 true false 135 120 165 165 180 210 180 240 150 300 165 300 195 240 195 195 165 135
  247. Circle -7500403 true true 85 132 38
  248. Circle -7500403 true true 130 147 38
  249. Circle -7500403 true true 192 85 38
  250. Circle -7500403 true true 85 40 38
  251. Circle -7500403 true true 177 40 38
  252. Circle -7500403 true true 177 132 38
  253. Circle -7500403 true true 70 85 38
  254. Circle -7500403 true true 130 25 38
  255. Circle -7500403 true true 96 51 108
  256. Circle -16777216 true false 113 68 74
  257. Polygon -10899396 true false 189 233 219 188 249 173 279 188 234 218
  258. Polygon -10899396 true false 180 255 150 210 105 210 75 240 135 240
  259. house
  260. false
  261. 0
  262. Rectangle -7500403 true true 45 120 255 285
  263. Rectangle -16777216 true false 120 210 180 285
  264. Polygon -7500403 true true 15 120 150 15 285 120
  265. Line -16777216 false 30 120 270 120
  266. leaf
  267. false
  268. 0
  269. Polygon -7500403 true true 150 210 135 195 120 210 60 210 30 195 60 180 60 165 15 135 30 120 15 105 40 104 45 90 60 90 90 105 105 120 120 120 105 60 120 60 135 30 150 15 165 30 180 60 195 60 180 120 195 120 210 105 240 90 255 90 263 104 285 105 270 120 285 135 240 165 240 180 270 195 240 210 180 210 165 195
  270. Polygon -7500403 true true 135 195 135 240 120 255 105 255 105 285 135 285 165 240 165 195
  271. line
  272. true
  273. 0
  274. Line -7500403 true 150 0 150 300
  275. line half
  276. true
  277. 0
  278. Line -7500403 true 150 0 150 150
  279. pentagon
  280. false
  281. 0
  282. Polygon -7500403 true true 150 15 15 120 60 285 240 285 285 120
  283. person
  284. false
  285. 0
  286. Circle -7500403 true true 110 5 80
  287. Polygon -7500403 true true 105 90 120 195 90 285 105 300 135 300 150 225 165 300 195 300 210 285 180 195 195 90
  288. Rectangle -7500403 true true 127 79 172 94
  289. Polygon -7500403 true true 195 90 240 150 225 180 165 105
  290. Polygon -7500403 true true 105 90 60 150 75 180 135 105
  291. plant
  292. false
  293. 0
  294. Rectangle -7500403 true true 135 90 165 300
  295. Polygon -7500403 true true 135 255 90 210 45 195 75 255 135 285
  296. Polygon -7500403 true true 165 255 210 210 255 195 225 255 165 285
  297. Polygon -7500403 true true 135 180 90 135 45 120 75 180 135 210
  298. Polygon -7500403 true true 165 180 165 210 225 180 255 120 210 135
  299. Polygon -7500403 true true 135 105 90 60 45 45 75 105 135 135
  300. Polygon -7500403 true true 165 105 165 135 225 105 255 45 210 60
  301. Polygon -7500403 true true 135 90 120 45 150 15 180 45 165 90
  302. square
  303. false
  304. 0
  305. Rectangle -7500403 true true 30 30 270 270
  306. square 2
  307. false
  308. 0
  309. Rectangle -7500403 true true 30 30 270 270
  310. Rectangle -16777216 true false 60 60 240 240
  311. star
  312. false
  313. 0
  314. Polygon -7500403 true true 151 1 185 108 298 108 207 175 242 282 151 216 59 282 94 175 3 108 116 108
  315. target
  316. false
  317. 0
  318. Circle -7500403 true true 0 0 300
  319. Circle -16777216 true false 30 30 240
  320. Circle -7500403 true true 60 60 180
  321. Circle -16777216 true false 90 90 120
  322. Circle -7500403 true true 120 120 60
  323. tree
  324. false
  325. 0
  326. Circle -7500403 true true 118 3 94
  327. Rectangle -6459832 true false 120 195 180 300
  328. Circle -7500403 true true 65 21 108
  329. Circle -7500403 true true 116 41 127
  330. Circle -7500403 true true 45 90 120
  331. Circle -7500403 true true 104 74 152
  332. triangle
  333. false
  334. 0
  335. Polygon -7500403 true true 150 30 15 255 285 255
  336. triangle 2
  337. false
  338. 0
  339. Polygon -7500403 true true 150 30 15 255 285 255
  340. Polygon -16777216 true false 151 99 225 223 75 224
  341. truck
  342. false
  343. 0
  344. Rectangle -7500403 true true 4 45 195 187
  345. Polygon -7500403 true true 296 193 296 150 259 134 244 104 208 104 207 194
  346. Rectangle -1 true false 195 60 195 105
  347. Polygon -16777216 true false 238 112 252 141 219 141 218 112
  348. Circle -16777216 true false 234 174 42
  349. Rectangle -7500403 true true 181 185 214 194
  350. Circle -16777216 true false 144 174 42
  351. Circle -16777216 true false 24 174 42
  352. Circle -7500403 false true 24 174 42
  353. Circle -7500403 false true 144 174 42
  354. Circle -7500403 false true 234 174 42
  355. turtle
  356. true
  357. 0
  358. Polygon -10899396 true false 215 204 240 233 246 254 228 266 215 252 193 210
  359. Polygon -10899396 true false 195 90 225 75 245 75 260 89 269 108 261 124 240 105 225 105 210 105
  360. Polygon -10899396 true false 105 90 75 75 55 75 40 89 31 108 39 124 60 105 75 105 90 105
  361. Polygon -10899396 true false 132 85 134 64 107 51 108 17 150 2 192 18 192 52 169 65 172 87
  362. Polygon -10899396 true false 85 204 60 233 54 254 72 266 85 252 107 210
  363. Polygon -7500403 true true 119 75 179 75 209 101 224 135 220 225 175 261 128 261 81 224 74 135 88 99
  364. wheel
  365. false
  366. 0
  367. Circle -7500403 true true 3 3 294
  368. Circle -16777216 true false 30 30 240
  369. Line -7500403 true 150 285 150 15
  370. Line -7500403 true 15 150 285 150
  371. Circle -7500403 true true 120 120 60
  372. Line -7500403 true 216 40 79 269
  373. Line -7500403 true 40 84 269 221
  374. Line -7500403 true 40 216 269 79
  375. Line -7500403 true 84 40 221 269
  376. x
  377. false
  378. 0
  379. Polygon -7500403 true true 270 75 225 30 30 225 75 270
  380. Polygon -7500403 true true 30 75 75 30 270 225 225 270
  381. @#$#@#$#@
  382. NetLogo 6.0-BETA2
  383. @#$#@#$#@
  384. @#$#@#$#@
  385. @#$#@#$#@
  386. @#$#@#$#@
  387. @#$#@#$#@
  388. default
  389. 0.0
  390. -0.2 0 0.0 1.0
  391. 0.0 1 1.0 0.0
  392. 0.2 0 0.0 1.0
  393. link direction
  394. true
  395. 0
  396. Line -7500403 true 150 150 90 180
  397. Line -7500403 true 150 150 210 180
  398. @#$#@#$#@
  399. 1
  400. @#$#@#$#@