# Articles by R on Chi's Impe[r]fect Blog

### Built-in Colour Names in R

September 7, 2019 |

Quite often when you just want to whip out some quick plots, I like to assign the colours by colour names. Some of my go-to colours are… tomato,darkorange,turquioise,darkgrey,lightgrey. Recently I realized that I can get all of built-in colour names available in R to use by ...

### Playing Around with Phyllotactic Spirals

January 28, 2019 |

I wanted to figure out how to create gif animation using the magick, so I decided I’ll try that out with ggplot2 spiral art. Loading up packages I’m definitely in love with “magick” right now :)
```library(tidyverse) ## for pretty much everything...
library(magick) ## I'm now a magick fan!!!
library(scales) ## Handy when it comes to scaling, but I also love show_col function
library(patchwork) ## put ggplot side by side easily :)

## Let's just set some of my favourite number.
phi <- (1 + sqrt(5)) / 2
golden_angle <- pi*(3-sqrt(5))```
Function To Draw Artwork Instead of creating data frame, then plot with ...

### Extracting colours from your images with Image Quantization

January 18, 2019 |

magick really does the “Magic!” I have been playing around bit with package “magick”, and I think I am now hooked… Although I haven’t been able to understand everything written in vignette just yet. One of function I got really excited is image_quantize. This function will reduce the ...

### Making Original Bingo – Heart Theme

January 5, 2019 |

I have learned how to draw a heart with mathmatical equation, in fact there are so many “curves” you can draw with equation. Amazing, right?!? You can find all sorts of different curves on Wolfram Mathworld site. I’m really curious how did people find equation itself for some of ...

### Bubble Packed Chart with R using packcircles package

December 21, 2018 |

Tableau has chart type called “Packed Bubble Chart”, while I haven’t really utilized packed bubble chart much, I always thought they are fun and beautiful. I wanted to try creating same chart using R, and I came across package called packcircles. Reading vignettes was really helpful to figure out ...

### Having bit of party with Material Colour Palette

December 8, 2018 |

Continuing on with my “slight?” obsession with colours… I love colours in “Material Colour Palette”. There various website that will lets you grab the colours by clicking, such as this one, but I just wanted to have little handy cheet sheet for myself, so I’ve decided I’ll do ...

### Plotting Traditional Colours of Japan

November 28, 2018 |

I was curious to know what colours were Traditional Colours of Japan. One of the site I came across showing 465 palettes of Japanese colour is this one. Japanese Site with 465 palettes of traditional colour. While site displays colour beautifully, to see every colour you need to scroll quite bit, so ...

### Utilizing K-means to extract colours from your favourite images

November 11, 2018 |

I have been playing with package called imager, documentation on this package was extremely helpful! I have read through “getting started” as well as few other tutorial & examples. I love colours… Tools like colourlovers, Adobe Color CC, Canva Color Palette Generators are great extracting colours from photo (or in general ...

### Voronoi diagram with ggvoronoi package with Train Station data

November 9, 2018 |

I’ve always been curious to make Voronoi diagram, I just think they are beautiful! When I came across data set with train stations in Japan. I instantly thought this would be great data sets to make Voronoi diagram! I’ve gotten data sets from (Ekidata)[http://www.ekidata.jp/] ...

### Phyllotaxis Sprial and Prime Numbers – Experiment

October 27, 2018 |

I recently tried out Data Camp’s project called “Phyllotaxis: Draw flowers using mathematics”. Now I’m hooked on drawing spirals using golden angle. Also the mathematical art on instructor’s blog, Fronkostin is just amazing! Separately on twitter, I’ve gotten message on art with prime number, and that ...

### Popular Halloween Candy on US State Grid Map

October 24, 2018 |

Halloween is coming..! Halloween is just around the corner, I am still trying to decide which candies to purchase this year for trick-or-treaters. Initially I was looking for data sets maybe comparing American chocolate bars vs Canadian chocolate bars possibly with sugar contents or lists of ingredients. I am really ...

### Cannibus Curve with ggplot2

October 16, 2018 |

Starting today, recreational weed is legal in Canada. This news has some how lead me to find Cannibus Curve, a mathmatical equation to draw Cannibus….!!! So to celebrate? being 2nd country in the world (1st was Uruguay) to legalize the green stuff for fun, I decided I’ll try drawing ...

### Random Walk of Pi – Another ggplot2 Experiment

October 13, 2018 |

There are so many beautiful “π” arts everywhere, and I wanted to practice ggplot2 by mimicing those arts further more. Another pi art caught my eye is random walk of pi digits. Here’s one of examples in WIRED magazine. For random walk to work, I’ve assigned direction to “walk” ...

### Visual Art with Pi using ggplot2 & circlize

October 12, 2018 |

I stumbled across this beautiful art on Washington Post article, and I wanted to try making the similar art using “digits in pi” myself using R and things I’ve learned recently. Get First 100000 digits of Pi After bit of googling, I stumbled across this this site, so I decided ...

### Environmental Performance Index – Simple Scatter Plot

October 4, 2018 |

While reading the news that Ireland becomes world’s first country to divest from fossil fuels, I just got curious how do we measure “green-ness” of country when we rank them in general, and I came across the Environmental Performance Index page with ranking table. Table contained 180 countries with some ...

### Making Calendar with ggplot + Moon Phase Calendar for fun

May 25, 2018 |

Making Calendar with ggplot2 I recently discovered font called Moon Phase. I also recently discovered R package, suncalc, and I can get Moon Illumination data by day, so I thought I’d use both to create a simple calendar using ggplot2. Prepping The Data To make calendar, I need to ...

### 16 Personalities with Circlize

May 19, 2018 |

16 Personalities While back, my husband introduced me to this fun online personalities test called 16 personalities. I’ve taken the test, and my personalities type came back as Mediator (Code: INFP - Role: Diplomat) There were difinitely some traits that sounded like me, and a lot of statement I can relate ...

### Daylight in Vancouver (Canada) vs Tokyo (Japan)

May 19, 2018 |

I currently live in British Columbia, Canada. So I live above 49th parallel line. One of things that’s pretty awesome living up north is the fact you get so much longer daylights in summer time! Currently it’s May, and I’m just in love with longe...

### Testing Entry with R Rmarkdown File

May 18, 2018 |

Hello! World! Just figuring out how the blog post works with this random set of coffee data! Espresso Drinks Visualized with ggplot2 Pie Chart Pie chart can be created with using polar coordinate.
```## Pie Chart
coffee_long  %>% ggplot() +
geom_bar(aes(x=sqrt(total.amount)/2, y = amount,
fill=fct_rev(ingredient.f), width=sqrt(total.amount)),
stat="identity", position="fill") +
facet_wrap(~name2, ncol=4) +
geom_text(aes(x=sqrt(total.amount), y=Inf, label=""), size=7) +
theme_void(base_family="Roboto Condensed") +
coord_polar(theta="y") +
scale_fill_hue(name="Ingredient", l=80) +
theme(legend.position="top")```
Espresso Drinks Visualized with ggplot2 Bar Chart
```## Bar Chart

coffee_long  %>% ggplot() +
geom_bar(aes(x=3, y = amount, fill=fct_rev(ingredient.f), width=sqrt(total.amount)/2),
stat="identity", position="stack") +
facet_wrap(~name2, ncol=4) +
theme_void(base_family="Roboto Condensed") +
scale_fill_hue(name="Ingredient", l=80) +
theme(legend.position="top")```