<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/tiny-art-in-less-than-280-characters/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://fronkonstin.com/2017/12/23/tiny-art-in-less-than-280-characters/"> R – Fronkonstin</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div class="twitter-share"><a rel="nofollow" href="https://twitter.com/intent/tweet?url=https%3A%2F%2Ffronkonstin.com%2F2017%2F12%2F23%2Ftiny-art-in-less-than-280-characters%2F&via=aschinchon" class="twitter-share-button" target="_blank">Tweet</a></div>
<p>Now that Twitter allows 280 characters, the code of some drawings I have made can fit in a tweet. In this post I have compiled a few of them.</p>
<p>The first one is a cardioid inspired in string art (more info <a rel="nofollow" href="https://fronkonstin.com/2015/07/08/the-moon-and-the-sun/" target="_blank">here</a>):</p>
<pre>
library(ggplot2)
n=300
t1=1:n
t0=seq(3,2*n+1,2)%%n
t2=t0+(t0==0)*n
df=data.frame(x=cos((t1-1)*2*pi/n), 
y=sin((t1-1)*2*pi/n),
x2=cos((t2-1)*2*pi/n),
y2=sin((t2-1)*2*pi/n))
ggplot(df,aes(x,y,xend=x2,yend=y2)) +
geom_segment(alpha=.1)+theme_void()
</pre>
<p><img data-orig-file="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2017/12/sun.jpg?fit=1200%2C1200&amp;ssl=1" data-orig-size="1200,1200" data-medium-file="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2017/12/sun.jpg?fit=300%2C300&amp;ssl=1" data-attachment-id="4344" data-image-meta="{" data-image-description="" src="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2017/12/sun.jpg?resize=480%2C480&ssl=1" data-permalink="https://fronkonstin.com/2017/12/23/tiny-art-in-less-than-280-characters/sun/" data-large-file="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2017/12/sun.jpg?fit=604%2C604&amp;ssl=1" alt="" data-image-title="sun" sizes="(max-width: 480px) 100vw, 480px" width="450" data-comments-opened="1" class="wp-image-4344" data-recalc-dims="1"><br>
This other is based on Fermat’s spiral (more info <a rel="nofollow" href="https://fronkonstin.com/2015/12/01/hypnotical-fermat/" target="_blank">here</a>):</p>
<pre>
library(ggplot2)
library(dplyr)
t=seq(from=0, to=100*pi, length.out=500*100)
data.frame(x= t^(1/2)*cos(t), y= t^(1/2)*sin(t))%>%
rbind(-.)%>%ggplot(aes(x, y))+geom_polygon()+theme_void()
</pre>
<p><img data-orig-file="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2017/12/hilbert.jpg?fit=1200%2C1200&amp;ssl=1" data-orig-size="1200,1200" data-medium-file="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2017/12/hilbert.jpg?fit=300%2C300&amp;ssl=1" data-attachment-id="4345" data-image-meta="{" data-image-description="" src="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2017/12/hilbert.jpg?resize=480%2C480&ssl=1" data-permalink="https://fronkonstin.com/2017/12/23/tiny-art-in-less-than-280-characters/hilbert-2/" data-large-file="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2017/12/hilbert.jpg?fit=604%2C604&amp;ssl=1" alt="" data-image-title="hilbert" sizes="(max-width: 480px) 100vw, 480px" width="450" data-comments-opened="1" class="wp-image-4345" data-recalc-dims="1"><br>
A recurrence plot of <i>Gauss error function</i> (more info <a rel="nofollow" href="https://fronkonstin.com/2015/07/01/trigonometric-pattern-design/" target="_blank">here</a>):</p>
<pre>
library(dplyr)
library(ggplot2)
library(pracma)
seq(-5*pi,5*pi,by=.1)%>%expand.grid(x=., y=.)%>%
ggplot(aes(x=x, y=y, fill=erf(sec(x)-sec(y))))+geom_tile()+
scale_fill_gradientn(colours=c(&quot;#000000&quot;,&quot;#FFFFFF&quot;))+
theme_void()+theme(legend.position=&quot;none&quot;)
</pre>
<p><img data-orig-file="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2017/12/pattern.jpg?fit=480%2C480&amp;ssl=1" data-orig-size="480,480" data-medium-file="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2017/12/pattern.jpg?fit=300%2C300&amp;ssl=1" data-attachment-id="4346" data-image-meta="{" data-image-description="" src="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2017/12/pattern.jpg?resize=480%2C480&ssl=1" data-permalink="https://fronkonstin.com/2017/12/23/tiny-art-in-less-than-280-characters/pattern/" data-large-file="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2017/12/pattern.jpg?fit=480%2C480&amp;ssl=1" alt="" data-image-title="pattern" sizes="(max-width: 480px) 100vw, 480px" width="450" data-comments-opened="1" class="wp-image-4346" data-recalc-dims="1"><br>
A x-y scatter plot of a trigonometric function on R<sup>2</sup> (more info <a rel="nofollow" href="https://fronkonstin.com/2016/03/01/a-silky-drawing-and-a-tiny-experiment/" target="_blank">here</a>):</p>
<pre>
library(dplyr)
library(ggplot2)
seq(from=-10, to=10, by = 0.05) %>%
expand.grid(x=., y=.) %>%
ggplot(aes(x=(x+pi*sin(y)), y=(y+pi*sin(x)))) +
geom_point(alpha=.1, shape=20, size=1, color=&quot;black&quot;)+
theme_void()
</pre>
<p><img data-orig-file="https://i2.wp.com/fronkonstin.com/wp-content/uploads/2017/12/silky.jpg?fit=1200%2C1200&amp;ssl=1" data-orig-size="1200,1200" data-medium-file="https://i2.wp.com/fronkonstin.com/wp-content/uploads/2017/12/silky.jpg?fit=300%2C300&amp;ssl=1" data-attachment-id="4347" data-image-meta="{" data-image-description="" src="https://i2.wp.com/fronkonstin.com/wp-content/uploads/2017/12/silky.jpg?resize=480%2C480&ssl=1" data-permalink="https://fronkonstin.com/2017/12/23/tiny-art-in-less-than-280-characters/silky-2/" data-large-file="https://i2.wp.com/fronkonstin.com/wp-content/uploads/2017/12/silky.jpg?fit=604%2C604&amp;ssl=1" alt="" data-image-title="silky" sizes="(max-width: 480px) 100vw, 480px" width="450" data-comments-opened="1" class="wp-image-4347" data-recalc-dims="1"><br>
A turtle graphic (more info <a rel="nofollow" href="https://fronkonstin.com/2014/07/07/four-simple-turtle-graphs-to-play-with-kids/" target="_blank">here</a>):</p>
<pre>
library(TurtleGraphics)
turtle_init()
turtle_col(&quot;gray25&quot;)
turtle_do({
  for (i in 1:150) {
    turtle_forward(dist=1+0.5*i)
    turtle_right(angle=89.5)}
})
turtle_hide()
</pre>
<p><img data-orig-file="https://i2.wp.com/fronkonstin.com/wp-content/uploads/2017/12/turtle.jpg?fit=1200%2C1200&amp;ssl=1" data-orig-size="1200,1200" data-medium-file="https://i2.wp.com/fronkonstin.com/wp-content/uploads/2017/12/turtle.jpg?fit=300%2C300&amp;ssl=1" data-attachment-id="4351" data-image-meta="{" data-image-description="" src="https://i2.wp.com/fronkonstin.com/wp-content/uploads/2017/12/turtle.jpg?resize=480%2C480&ssl=1" data-permalink="https://fronkonstin.com/2017/12/23/tiny-art-in-less-than-280-characters/turtle/" data-large-file="https://i2.wp.com/fronkonstin.com/wp-content/uploads/2017/12/turtle.jpg?fit=604%2C604&amp;ssl=1" alt="" data-image-title="turtle" sizes="(max-width: 480px) 100vw, 480px" width="450" data-comments-opened="1" class="wp-image-4351" data-recalc-dims="1"><br>
A curve generated by a <i>simulated</i> harmonograph (more info <a rel="nofollow" href="https://fronkonstin.com/2014/10/13/beautiful-curves-the-harmonograph/" target="_blank">here</a>):</p>
<pre>
t=seq(1, 100, by=.001)
plot(exp(-0.006*t)*sin(t*3.019+2.677)+
exp(-0.001*t)*sin(t*2.959+2.719),
exp(-0.009*t)*sin(t*2.964+0.229)+
exp(-0.008*t)*sin(t*2.984+1.284), 
type=&quot;l&quot;, axes=FALSE, xlab=&quot;&quot;, ylab=&quot;&quot;)
</pre>
<p><img data-orig-file="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2017/12/harmonograph.jpg?fit=1200%2C1200&amp;ssl=1" data-orig-size="1200,1200" data-medium-file="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2017/12/harmonograph.jpg?fit=300%2C300&amp;ssl=1" data-attachment-id="4352" data-image-meta="{" data-image-description="" src="https://i2.wp.com/fronkonstin.com/wp-content/uploads/2017/12/harmonograph2.jpg?resize=480%2C480&ssl=1" data-permalink="https://fronkonstin.com/2017/12/23/tiny-art-in-less-than-280-characters/harmonograph/" data-large-file="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2017/12/harmonograph.jpg?fit=604%2C604&amp;ssl=1" alt="" data-image-title="harmonograph" width="450" data-comments-opened="1" class="wp-image-4352" data-recalc-dims="1"><br>
A chord diagram of a 20×20 1-matrix (more info <a rel="nofollow" href="https://fronkonstin.com/2016/08/22/the-breathtaking-1-matrix/" target="_blank">here</a>):</p>
<pre>
library(circlize)
chordDiagram(matrix(1, 20, 20), symmetric = TRUE, 
col=&quot;black&quot;, transparency = 0.85, annotationTrack = NULL)
</pre>
<p><img alt="" width="450" src="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2017/12/chord2.jpg?resize=480%2C480&ssl=1" class="wp-image-4360" data-recalc-dims="1"><br>
Most of them are made with <code>ggplot2</code> package. I love R and the sense of wonder of how just one or two lines of code can create beautiful and unexpected patterns.</p>
<p>I recently did <a rel="nofollow" href="https://www.datacamp.com/projects/62?tap_a=5644-dce66f&tap_s=10907-287229" target="_blank">this project</a> for DataCamp to show how easy is to do art with R and <code>ggplot</code>. Starting from a extremely simple plot, and following a well guided path, you can end making beautiful images like this one:<br>
<img data-orig-file="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2017/12/flower.jpg?fit=822%2C824&amp;ssl=1" data-orig-size="822,824" data-medium-file="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2017/12/flower.jpg?fit=300%2C300&amp;ssl=1" data-attachment-id="4360" data-image-meta="{" data-image-description="" src="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2017/12/flower.jpg?resize=480%2C480&ssl=1" data-permalink="https://fronkonstin.com/2017/12/23/tiny-art-in-less-than-280-characters/flower-2/" data-large-file="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2017/12/flower.jpg?fit=604%2C605&amp;ssl=1" alt="" data-image-title="flower" sizes="(max-width: 480px) 100vw, 480px" width="450" data-comments-opened="1" class="wp-image-4360" data-recalc-dims="1"><br>
Furthermore, you can learn also <code>ggplot2</code> while you do art.</p>
<p>I have done the project together with <a rel="nofollow" href="https://twitter.com/rabaath" target="_blank">Rasmus Bååth</a>, instructor at DataCamp and the perfect mate to work with. He is looking for people to build more projects so if you are interested, <a rel="nofollow" href="https://authoring.datacamp.com/projects/?tap_a=5644-dce66f&tap_s=10907-287229" target="_blank">here</a> you can find more information. Do not hesitate to ask him for details.</p>
<p>All the best for 2018.</p>
<p>Merry Christmas.</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://fronkonstin.com/2017/12/23/tiny-art-in-less-than-280-characters/"> R – Fronkonstin</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 alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/TaYNf2aY0Ao" height="1"></a></div>