<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/sunflowers-for-colourlovers/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://fronkonstin.com/2017/05/22/sunflowers-for-colourlovers/"> 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 target="_blank" class="twitter-share-button" rel="nofollow" href="https://twitter.com/intent/tweet?url=https%3A%2F%2Ffronkonstin.com%2F2017%2F05%2F22%2Fsunflowers-for-colourlovers%2F&via=aschinchon">Tweet</a></div>
<blockquote><p>Andar, lo que es andar, anduve encima siempre de las nubes (Del tiempo perdido, Robe)</p>
</blockquote>
<p>If you give importance to colours, maybe you know already <a target="_blank" rel="nofollow" href="http://www.colourlovers.com/">COLOURlovers</a>. As can be read in their website, <em>COLOURlovers is a creative community where people from around the world create and share colors, palettes and patterns, discuss the latest trends and explore colorful articles… All in the spirit of love</em>.</p>
<p>There is a R package called <a target="_blank" rel="nofollow" href="https://cran.r-project.org/web/packages/colourlovers/index.html">colourlovers</a> which provides access to the COLOURlovers API. It makes very easy to choose nice colours for your graphics. I used clpalettes function to search for the top palettes of the website. Their names are pretty suggestive as well: Giant Goldfish, Thought Provoking, Adrift in Dreams, let them eat cake … Inspired by <a target="_blank" rel="nofollow" href="https://fronkonstin.com/2015/12/14/phyllotaxis-by-shiny/">this post</a> I have done a Shiny app to create colored flowers using that palettes. Seeds are arranged according to the <a target="_blank" rel="nofollow" href="https://en.wikipedia.org/wiki/Golden_angle">golden angle</a>. One example:<br>
<img sizes="(max-width: 604px) 100vw, 604px" data-image-description="" data-orig-file="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower2.png?fit=825%2C825&amp;ssl=1" data-orig-size="825,825" data-image-title="flower2" class="wp-image-4076" data-comments-opened="1" data-recalc-dims="1" data-attachment-id="4076" data-permalink="https://fronkonstin.com/2017/05/22/sunflowers-for-colourlovers/flower2/" alt="" data-medium-file="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower2.png?fit=300%2C300&amp;ssl=1" data-large-file="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower2.png?fit=604%2C604&amp;ssl=1" data-image-meta="{" src="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower2.png?w=450&ssl=1"><br>
Some others:</p>
<p><a target="_blank" rel="nofollow" href="https://fronkonstin.com/2017/05/22/sunflowers-for-colourlovers/flower3/"><img sizes="(max-width: 150px) 100vw, 150px" data-image-description="" data-orig-file="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower3.png?fit=825%2C825&amp;ssl=1" data-orig-size="825,825" width="150" data-image-title="flower3" data-comments-opened="1" data-attachment-id="4077" height="150" data-permalink="https://fronkonstin.com/2017/05/22/sunflowers-for-colourlovers/flower3/" alt="" data-medium-file="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower3.png?fit=300%2C300&amp;ssl=1" data-large-file="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower3.png?fit=604%2C604&amp;ssl=1" data-image-meta="{" src="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower3.png?resize=150%2C150&ssl=1"></a><br>
<a target="_blank" rel="nofollow" href="https://fronkonstin.com/2017/05/22/sunflowers-for-colourlovers/flower5/"><img sizes="(max-width: 150px) 100vw, 150px" data-image-description="" data-orig-file="https://i2.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower5.png?fit=825%2C825&amp;ssl=1" data-orig-size="825,825" width="150" data-image-title="flower5" data-comments-opened="1" data-attachment-id="4078" height="150" data-permalink="https://fronkonstin.com/2017/05/22/sunflowers-for-colourlovers/flower5/" alt="" data-medium-file="https://i2.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower5.png?fit=300%2C300&amp;ssl=1" data-large-file="https://i2.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower5.png?fit=604%2C604&amp;ssl=1" data-image-meta="{" src="https://i2.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower5.png?resize=150%2C150&ssl=1"></a><br>
<a target="_blank" rel="nofollow" href="https://fronkonstin.com/2017/05/22/sunflowers-for-colourlovers/flower7/"><img sizes="(max-width: 150px) 100vw, 150px" data-image-description="" data-orig-file="https://i2.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower7.png?fit=825%2C825&amp;ssl=1" data-orig-size="825,825" width="150" data-image-title="flower7" data-comments-opened="1" data-attachment-id="4080" height="150" data-permalink="https://fronkonstin.com/2017/05/22/sunflowers-for-colourlovers/flower7/" alt="" data-medium-file="https://i2.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower7.png?fit=300%2C300&amp;ssl=1" data-large-file="https://i2.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower7.png?fit=604%2C604&amp;ssl=1" data-image-meta="{" src="https://i2.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower7.png?resize=150%2C150&ssl=1"></a><br>
<a target="_blank" rel="nofollow" href="https://fronkonstin.com/flower11/"><img sizes="(max-width: 150px) 100vw, 150px" data-image-description="" data-orig-file="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower11.png?fit=825%2C825&amp;ssl=1" data-orig-size="825,825" width="150" data-image-title="flower11" data-comments-opened="1" data-attachment-id="4084" height="150" data-permalink="https://fronkonstin.com/flower11/" alt="" data-medium-file="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower11.png?fit=300%2C300&amp;ssl=1" data-large-file="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower11.png?fit=604%2C604&amp;ssl=1" data-image-meta="{" src="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower11.png?resize=150%2C150&ssl=1"></a><br>
<a target="_blank" rel="nofollow" href="https://fronkonstin.com/flower10/"><img sizes="(max-width: 150px) 100vw, 150px" data-image-description="" data-orig-file="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower10.png?fit=825%2C825&amp;ssl=1" data-orig-size="825,825" width="150" data-image-title="flower10" data-comments-opened="1" data-attachment-id="4083" height="150" data-permalink="https://fronkonstin.com/flower10/" alt="" data-medium-file="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower10.png?fit=300%2C300&amp;ssl=1" data-large-file="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower10.png?fit=604%2C604&amp;ssl=1" data-image-meta="{" src="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower10.png?resize=150%2C150&ssl=1"></a><br>
<a target="_blank" rel="nofollow" href="https://fronkonstin.com/2017/05/22/sunflowers-for-colourlovers/flower9/"><img sizes="(max-width: 150px) 100vw, 150px" data-image-description="" data-orig-file="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower9.png?fit=825%2C825&amp;ssl=1" data-orig-size="825,825" width="150" data-image-title="flower9" data-comments-opened="1" data-attachment-id="4082" height="150" data-permalink="https://fronkonstin.com/2017/05/22/sunflowers-for-colourlovers/flower9/" alt="" data-medium-file="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower9.png?fit=300%2C300&amp;ssl=1" data-large-file="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower9.png?fit=604%2C604&amp;ssl=1" data-image-meta="{" src="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower9.png?resize=150%2C150&ssl=1"></a><br>
<a target="_blank" rel="nofollow" href="https://fronkonstin.com/2017/05/22/sunflowers-for-colourlovers/flower8/"><img sizes="(max-width: 150px) 100vw, 150px" data-image-description="" data-orig-file="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower8.png?fit=825%2C825&amp;ssl=1" data-orig-size="825,825" width="150" data-image-title="flower8" data-comments-opened="1" data-attachment-id="4081" height="150" data-permalink="https://fronkonstin.com/2017/05/22/sunflowers-for-colourlovers/flower8/" alt="" data-medium-file="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower8.png?fit=300%2C300&amp;ssl=1" data-large-file="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower8.png?fit=604%2C604&amp;ssl=1" data-image-meta="{" src="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower8.png?resize=150%2C150&ssl=1"></a><br>
<a target="_blank" rel="nofollow" href="https://fronkonstin.com/2017/05/22/sunflowers-for-colourlovers/flower6/"><img sizes="(max-width: 150px) 100vw, 150px" data-image-description="" data-orig-file="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower6.png?fit=825%2C825&amp;ssl=1" data-orig-size="825,825" width="150" data-image-title="flower6" data-comments-opened="1" data-attachment-id="4079" height="150" data-permalink="https://fronkonstin.com/2017/05/22/sunflowers-for-colourlovers/flower6/" alt="" data-medium-file="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower6.png?fit=300%2C300&amp;ssl=1" data-large-file="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower6.png?fit=604%2C604&amp;ssl=1" data-image-meta="{" src="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower6.png?resize=150%2C150&ssl=1"></a><br>
<a target="_blank" rel="nofollow" href="https://fronkonstin.com/2017/05/22/sunflowers-for-colourlovers/flower12/"><img sizes="(max-width: 150px) 100vw, 150px" data-image-description="" data-orig-file="https://i2.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower12.png?fit=825%2C825&amp;ssl=1" data-orig-size="825,825" width="150" data-image-title="flower12" data-comments-opened="1" data-attachment-id="4087" height="150" data-permalink="https://fronkonstin.com/2017/05/22/sunflowers-for-colourlovers/flower12/" alt="" data-medium-file="https://i2.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower12.png?fit=300%2C300&amp;ssl=1" data-large-file="https://i2.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower12.png?fit=604%2C604&amp;ssl=1" data-image-meta="{" src="https://i2.wp.com/fronkonstin.com/wp-content/uploads/2017/05/flower12.png?resize=150%2C150&ssl=1"></a></p>
<p>You can play with the app <a target="_blank" rel="nofollow" href="http://91.134.134.147:3838/flowers/">here</a>.</p>
<p>If you want to do your own sunflowers, here you have the code. This is the <code>ui.R</code> file:</p>
<pre>
library(colourlovers)
library(rlist)
top=clpalettes('top')
sapply(1:length(top), function(x) list.extract(top, x)$title)->titles

fluidPage(
  titlePanel(&quot;Sunflowers for COLOURlovers&quot;),
  fluidRow(
    column(3,
           wellPanel(
             selectInput(&quot;pal&quot;, label = &quot;Palette:&quot;, choices = titles),
             sliderInput(&quot;nob&quot;, label = &quot;Number of points:&quot;, min = 200, max = 500, value = 400, step = 50)
           )
    ),
    mainPanel(
      plotOutput(&quot;Flower&quot;)
    )
  )
  )
</pre>
<p>And this is the <code>server.R</code> one:</p>
<pre>
library(shiny)
library(ggplot2)
library(colourlovers)
library(rlist)
library(dplyr)

top=clpalettes('top')
sapply(1:length(top), function(x) list.extract(top, x)$title)->titles

CreatePlot = function (ang=pi*(3-sqrt(5)), nob=150, siz=15, sha=21, pal=&quot;LoversInJapan&quot;) {
  
  list.extract(top, which(titles==pal))$colors %>% 
    unlist %>% 
    as.vector() %>% 
    paste0(&quot;#&quot;, .) -> all_colors
  
  colors=data.frame(hex=all_colors, darkness=colSums(col2rgb(all_colors)))
  colors %>% arrange(-darkness)->colors
  
  background=colors[1,&quot;hex&quot;] %>% as.character

  colors %>% filter(hex!=background) %>% .[,1] %>% as.vector()->colors

  ggplot(data.frame(r=sqrt(1:nob), t=(1:nob)*ang*pi/180), aes(x=r*cos(t), y=r*sin(t)))+
    geom_point(colour=sample(colors, nob, replace=TRUE, prob=exp(1:length(colors))), aes(size=(nob-r)), shape=16)+
    scale_x_continuous(expand=c(0,0), limits=c(-sqrt(nob)*1.4, sqrt(nob)*1.4))+
    scale_y_continuous(expand=c(0,0), limits=c(-sqrt(nob)*1.4, sqrt(nob)*1.4))+
    theme(legend.position=&quot;none&quot;,
          panel.background = element_rect(fill=background),
          panel.grid=element_blank(),
          axis.ticks=element_blank(),
          axis.title=element_blank(),
          axis.text=element_blank())}

function(input, output) {
 output$Flower=renderPlot({
    CreatePlot(ang=180*(3-sqrt(5)), nob=input$nob, siz=input$siz, sha=as.numeric(input$sha), pal=input$pal)
  }, height = 550, width = 550 )}
</pre>
<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/05/22/sunflowers-for-colourlovers/"> 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 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/UZqrqW995JI"></a></div>