I’ve written code and recorded videos to show each step. Let’s break apart this function piece by piece in order to see how it works. highlight_color sets the color of the donut chart and the big number.font_family to use any font for the big number (of course, you have to have the font installed in order for it to work).For this function, I assume it’s a percentage (you could adjust the function for non-percentages). value is the number (from 0 to 1) that we want to highlight.In order to use the function, we’d write code like this. # Add the big number in the center of the hole # Set theme_void() to remove grid lines and everything else from the plot Scale_fill_manual(values = c(highlight_color, "grey90")) + # Set a color scale with the highlighted section in whatever color # is chosen with the highlight_color argument and the rest in a light gray # Set the limits, which is important for adding the hole # A pie/donut chart is a bar chart with polar coordinates # Add polar coordinates and set the direction to -1 # so the filled in part starts at the top and goes clockwise # Create a nicely formatted big number to go in the donut holeīig_number_text_label <- percent(value, accuracy = 1) Plot the donut chart and add the big number to the middle of it. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |