Creating pretty dials

1 d3w3uiLunDng-Cuj6rEO-A

R can do a lot of things really really well, but one thing it struggles to do (at least in base R anyway) is to create pretty visuals. I have recently been creating visuals for some clients and wrote some code to produce some pretty dials in R. I will start by building a simple dial, and then adding various bits to it.

1.Simple dial

###Create a sequence from your breaks

###Creating the dial shape
get.poly <- function(a,b,r1=0.5,r2=1.0) {
 th.start <- pi*(1-a/100)
 th.end <- pi*(1-b/100)
 th <- seq(th.start,th.end,length=100)
 x <- c(r1*cos(th),rev(r2*cos(th)))
 y <- c(r1*sin(th),rev(r2*sin(th)))

###A nice big empty plotting area
###Dialling in the numbers
#Where you want the dial to finish

#The coloured section up to your position

#From your position to the end of the dial

Ta da! Here we have the output for the most simple of simple dials

1 On-eNjk5ksLXrlm5Q6fHHQ

Author: Jamie Samson

I am Head of Data Science and Insights at I am a lover of R and consider myself an Rtist in data visualisations.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s