<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/happy-pi-day-2/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.theanalyticslab.nl/2017/03/14/happy-pi-day/"> Rbloggers – The Analytics Lab</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Just something funny because it’s  <a target="_blank" rel="nofollow" href="https://i1.wp.com/www.theanalyticslab.nl/wp-content/uploads/2017/03/pi.png"><img alt="pi" class="wp-image-1222" src="https://i2.wp.com/www.theanalyticslab.nl/wp-content/uploads/2017/03/pi-80x80.png?resize=40%2C36" data-recalc-dims="1"></a> day. Enjoy!</p>
<pre># clear your environment
rm(list = ls())</pre>
<pre># load the necessary libraries
library(png)
library(plotrix)</pre>
<pre># lab kleuren
oranje &lt;- rgb(228/255, 86/255, 65/255)
donkergrijs &lt;- rgb(75/255, 75/255, 74/255)
lichtblauw &lt;- rgb(123/255, 176/255, 231/255)</pre>
<pre># read the image of pi
img = readPNG(&quot;C:/Users/j.schoonemann/Desktop/pi.png&quot;)</pre>
<pre># read the logo of The Analytics Lab
logo = readPNG(&quot;C:/Users/j.schoonemann/Desktop/Lab.png&quot;)</pre>
<pre># define the x-position of the pie charts
x_position &lt;- c(2, 4, 8, 14, 22)</pre>
<pre># define the y-position of the pie charts
y_position &lt;- c(4, 6, 8, 10, 12)</pre>
<pre># define the size of the pie charts
pie_size &lt;- c(0.5,1.0,1.5,2.0,2.5)</pre>
<pre># create PacMan pie-charts
pacman &lt;- list(c(20,80), c(20,80), c(20,80), c(20,80), c(20,80))</pre>
<pre># calculate the chart limits for the x-axis
x_axis &lt;- c(min(x_position - pie_size), max(x_position + pie_size))</pre>
<pre># calculate the chart limits for the y-axis
y_axis &lt;- c(min(y_position - pie_size),max(y_position + pie_size))</pre>
<pre># define the colors of the PacMan pie-charts 
sector_col&lt;- c(&quot;black&quot;, &quot;yellow&quot;)</pre>
<pre># define the startposition of the first slice of the pie in the charts
start_position &lt;- c(-0.1, -0.2, -0.3, -0.4, -0.5)</pre>
<pre># create the canvas for the plot
plot(0, xlim = x_axis, ylim = y_axis, type = &quot;n&quot;, axes = F, xlab = &quot;&quot;, ylab = &quot;&quot;)</pre>
<pre># add a title and subtitle to the plot, adjust size and color
title(main = &quot;Eating Pi makes PacMan grow!\nHappy pi(e) day!&quot;, col.main = lichtblauw, cex.main = 2, 
 sub = &quot;Powered by: The Analytics Lab&quot;, col.sub = oranje, cex.sub = 1)</pre>
<pre># plot all the PacMan pie-charts
for(bubble in 1:length(x_position)){ 
 floating.pie(xpos = x_position[bubble], ypos = y_position[bubble], x = pacman[[bubble]], radius = pie_size[bubble], col = sector_col, startpos = start_position[bubble]) 
}</pre>
<pre># add the logo of The Analytics Lab to the plot
rasterImage(image = logo, xleft = 0, ybottom = 12, xright = 5, ytop = 16)</pre>
<pre># add pi multiple times to the plot
# pi between 1st and 2nd
rasterImage(image = img, xleft = 2.5, ybottom = 4.5, xright = 3.5, ytop = 5)
# pi between 2nd and 3d
rasterImage(image = img, xleft = 5, ybottom = 6.5, xright = 6, ytop = 7)
rasterImage(image = img, xleft = 5.8, ybottom = 7, xright = 6.8, ytop = 7.5)
# pi between 3d and 4th
rasterImage(image = img, xleft = 10, ybottom = 8.5, xright = 11, ytop = 9)
rasterImage(image = img, xleft = 11, ybottom = 9, xright = 12, ytop = 9.5)
# pi between 4th and 5th
rasterImage(image = img, xleft = 16.2, ybottom = 10, xright = 17.2, ytop = 10.5)
rasterImage(image = img, xleft = 17, ybottom = 10.5, xright = 18, ytop = 11)
rasterImage(image = img, xleft = 18, ybottom = 11, xright = 19, ytop = 11.5)</pre>
<p><a target="_blank" rel="nofollow" href="https://i0.wp.com/www.theanalyticslab.nl/wp-content/uploads/2017/03/Happy_pi_day.jpeg"><img sizes="(max-width: 521px) 100vw, 521px" alt="Happy_pi_day" class="wp-image-1221" src="https://i0.wp.com/www.theanalyticslab.nl/wp-content/uploads/2017/03/Happy_pi_day.jpeg?w=450" data-recalc-dims="1"></a></p>
<p> </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="http://www.theanalyticslab.nl/2017/03/14/happy-pi-day/"> Rbloggers – The Analytics Lab</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 title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/b-uqeEb2MMw"></a></div>