<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/cannibus-curve-with-ggplot2/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://chichacha.netlify.com/2018/10/17/cannibus-curve-with-ggplot2/"> R on Chi's Impe[r]fect Blog</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Starting today, recreational weed is legal in Canada. This news has some how lead me to find <a rel="nofollow" href="http://mathworld.wolfram.com/CannabisCurve.html" target="_blank">Cannibus Curve</a>, a mathmatical equation to draw Cannibus….!!!</p>
<p>So to celebrate? being 2nd country in the world (1st was <a rel="nofollow" href="http://fortune.com/2018/10/17/canada-marijuana-weed-legalization-uruguay/" target="_blank">Uruguay</a>) to legalize the green stuff for fun, I decided I’ll try drawing cannibus curve with ggplot. Here’s the final results.</p>
<div>
<img alt="Cannibus_Final" src="https://i0.wp.com/chichacha.netlify.com/post/2018-10-17-cannibus-curve-with-ggplot2_files/cannibus.png?w=450&ssl=1" data-recalc-dims="1">
<p>Cannibus_Final</p>
</div>
<p>Here’s the step I took, because I couldn’t really understand the mathmatical equation, so I’ve break it down step by step to sort of understand what each part of equation is doing.</p>
<pre><code>library(tidyverse)

cannibus &lt;- tibble(
  t = seq(-pi,pi, length.out=1000),
  r1 = (1+.9*cos(8*t)), ## this will draw 8 petals  ## this number determines number of leafs!
  r2 = r1 * (1+.1*cos(24*t)), ## this make it pointy
  r3 = r2 * (.9+0.5*cos(200*t)), ## this makes it jaggy
  r4 = r3 * (1+sin(t)), ## Hmm.. I think I want to rorate it 90 degree... 
  r4_alt = r3 * (1+sin(t-pi/2)), ## one way to do it...
  r = (1+.9*cos(8*t)) * (1+.1*cos(24*t)) * (.9+0.5*cos(200*t)) * (1+sin(t))  ## Put all in line line!
) 

cannibus %>% 
  ggplot(aes(x=t, y=r1)) + 
  geom_path(color=&quot;#7ABA71&quot;, size=2) +
  coord_polar() +
  theme_void(base_family=&quot;Roboto Condensed&quot;) +
  labs(title = &quot;(1+.9*cos(8*t) draws 8 petals&quot;)</code></pre>
<p><img src="https://i0.wp.com/chichacha.netlify.com/post/2018-10-17-cannibus-curve-with-ggplot2_files/figure-html/demystify_cannibus-1.png?w=450&ssl=1" data-recalc-dims="1"></p>
<pre><code>cannibus %>% 
  ggplot(aes(x=t, y=r2)) + 
  geom_path(color=&quot;#7ABA71&quot;, size=2) +
  coord_polar() +
  theme_void(base_family=&quot;Roboto Condensed&quot;) +
  labs(title = &quot;(1+.9*cos(8*t) * * (1+.1*cos(24*t)) makes the tip pointy&quot;)</code></pre>
<p><img src="https://i1.wp.com/chichacha.netlify.com/post/2018-10-17-cannibus-curve-with-ggplot2_files/figure-html/demystify_cannibus-2.png?w=450&ssl=1" data-recalc-dims="1"></p>
<pre><code>cannibus %>% 
  ggplot(aes(x=t, y=r3)) + 
  geom_path(color=&quot;#7ABA71&quot;, size=0.5) +
  coord_polar() +
  theme_void(base_family=&quot;Roboto Condensed&quot;) +
  labs(title = &quot;(1+.9*cos(8*t) * * (1+.1*cos(24*t)) * (.9+0.5*cos(200*t)) makes zaggy&quot;)</code></pre>
<p><img src="https://i0.wp.com/chichacha.netlify.com/post/2018-10-17-cannibus-curve-with-ggplot2_files/figure-html/demystify_cannibus-3.png?w=450&ssl=1" data-recalc-dims="1"></p>
<pre><code>cannibus %>% 
  ggplot(aes(x=t, y=r4)) + 
  geom_path(color=&quot;#7ABA71&quot;, size=0.5) +
  coord_polar(start=pi/2) +
  theme_void(base_family=&quot;Roboto Condensed&quot;) +
  labs(title = &quot;(1+.9*cos(8*t) * * (1+.1*cos(24*t)) * (.9+0.5*cos(200*t)) * (1+sin(t)) - OK Cool, Now 2 leaves are small!&quot;, subcaption=&quot;Notice I used start=pi/2 to rotate!&quot;)</code></pre>
<p><img src="https://i1.wp.com/chichacha.netlify.com/post/2018-10-17-cannibus-curve-with-ggplot2_files/figure-html/demystify_cannibus-4.png?w=450&ssl=1" data-recalc-dims="1"></p>
<pre><code>cannibus %>% 
  ggplot(aes(x=t, y=r)) + 
  geom_polygon(fill=&quot;#499b4a&quot;, color=&quot;#74Ba71&quot;, size=0.1) +
  coord_polar(theta=&quot;x&quot;, start=pi/2) +
  theme_void(base_family=&quot;Roboto Condensed&quot;) +
  labs(title = &quot;Instead of using geom_path, I used geom_polygon&quot;)</code></pre>
<p><img src="https://i2.wp.com/chichacha.netlify.com/post/2018-10-17-cannibus-curve-with-ggplot2_files/figure-html/demystify_cannibus-5.png?w=450&ssl=1" data-recalc-dims="1"></p>
<p>I couldn’t figure out how to “crop” the polar coordinate image, so there’s lots of white space on final image, but I like my little cannibus!</p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://chichacha.netlify.com/2018/10/17/cannibus-curve-with-ggplot2/"> R on Chi's Impe[r]fect Blog</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/gXUbBNDB-nA" height="1"></a></div>