X-Git-Url: http://git.vanrenterghem.biz/www2.vanrenterghem.biz.git/blobdiff_plain/6550448e6f262f9ef843bef2f9bc783aabff7163..3c9920148567c38da1fd09f8665264c436d85a8a:/source/posts/Fibonacci_golden_spiral.org diff --git a/source/posts/Fibonacci_golden_spiral.org b/source/posts/Fibonacci_golden_spiral.org index c4eeed8..948ac3c 100644 --- a/source/posts/Fibonacci_golden_spiral.org +++ b/source/posts/Fibonacci_golden_spiral.org @@ -3,7 +3,7 @@ #+LANGUAGE: en #+PROPERTY: session *R* #+PROPERTY: cache yes -#+PROPERTY: results graphics +#+PROPERTY: results file graphics #+PROPERTY: exports both #+PROPERTY: tangle yes #+OPTIONS: toc:nil @@ -301,17 +301,17 @@ dist_from_origin <- sapply(seq_theta,polar_golden_spiral) | 46.7443082659106 | Plotting the function using coord_polar in ggplot2 does not work as intended. Unexpectedly, the x axis keeps extending instead of circling back once a full circle is reached. Turns out coord_polar might not really be intended to plot elements in polar vector format. -#+BEGIN_SRC R :session R :results output graphics :file ../pics/golden_spiral-coord_polar-fail.png :exports both +#+BEGIN_SRC R :session R :results output file graphics :file ../assets/golden_spiral-coord_polar-fail.png :exports both ggplot(data.frame(x = seq_theta, y = dist_from_origin), aes(x,y)) + geom_point() + coord_polar(theta="x") #+END_SRC #+RESULTS: -[[file:../pics/golden_spiral-coord_polar-fail.png]] +[[file:../assets/golden_spiral-coord_polar-fail.png]] To ensure what I was trying to do is possible, I employ a specialised plotfunction instead -#+BEGIN_SRC R :session R :results output graphics :file ../pics/golden_spiral-plotrix.png :exports both +#+BEGIN_SRC R :session R :results output file graphics :file ../assets/golden_spiral-plotrix.png :exports both plotrix::radial.plot(dist_from_origin, seq_theta,rp.type="s", point.col = "blue") #+END_SRC @@ -339,7 +339,7 @@ df <- data.frame(t(serie)) * Result With everything now ready in the right coordinate system, it's now only a matter of setting some options to make the output look acceptable. -#+BEGIN_SRC R :session R :results output graphics :file ../pics/golden_spiral-ggplot-coord-fixed.png :width 800 :height 800 :exports both +#+BEGIN_SRC R :session R :results output file graphics :file ../assets/golden_spiral-ggplot-coord-fixed.png :width 800 :height 800 :exports both ggplot(df, aes(x=X1,y=X2)) + geom_path(color="blue") + theme(panel.grid.minor = element_blank(),