A gauge is a very common chart used in information dashboards; you can use a gauge when
you want to show a single value within a given scale. These charts typically show a key
indicator within a range of values, employing a semaphoric color code (eg green, yellow,
red). Although some people say gauges provide very little information for the amount of
space they consume, we’re not going to discuss whether gauges are good or bad, or what
type of colors we should use. We’re just going to see how we can create gauges in R.
Look at the following gauge from google charts:
We can distinguish the following elements:
circles (black and grey circles in the circumference)
bands (yellow and red stripes)
minimum and maximum values (0, 100)
value (eg 90)
blue point in the middle
The idea is to break down the chart into its different components so we can have a better
idea of how to create a gauge chart in R.
We will need three auxiliary functions to produce the circles, the stripe-bands, and the
tick marks around the gauge. Keep in mind that we will be working going back and forth
between radians and degrees to get the x-y coordinates of the elements we’re going to plot.
After defining the handy functions, we need to create the components that will be
plotted: the black border, the gray circles, the yellow stripe, the red stripe, the
major tick marks, the minor tick marks, the coordinates of the minimum and maximum
values, the value indicator, the needle, and the label. Here’s how we can define all
Putting everything together
Once we have all the ingredients, the last step is to put them all together in a plot