Search code examples
rggplot2plotbar-chartradial

Create a special Radial bar chart (race track plot)


I was able to replicate another good answers here to create a basic radial plot, but can anyone give me any clue of others functions/parameters/ideas on how to convert the basic one to something similar to this : enter image description here


Solution

  • You could get pretty close like this:

    df <- data.frame(x = c(10, 12.5, 15), y = c(1:3),
                     col = c("#fcfbfc", "#fbc3a0", "#ec6f4a"))
    
    library(ggplot2)
    
    ggplot(df, aes(x = 0, xend = x, y = y, yend = y, color = col)) +
      geom_hline(yintercept = c(1:3), size = 14, color = "#dfdfdf") +
      geom_hline(yintercept = c(1:3), size = 13, color = "#f7f7f7") +
      geom_segment(color = "#bf2c23", size = 14, lineend = 'round') +
      geom_segment(size = 13, lineend = 'round') +
      scale_color_identity() +
      geom_point(aes(x = x - 0.03 * y), size = 5, color = "#bf2c23", 
                 shape = 21, fill = 'white') +
      geom_point(aes(x = x - 0.03 * y), size = 2, color = "#bf2c23", 
                 shape = 21, fill = 'white') +
      scale_y_continuous(limits = c(0, 4)) +
      scale_x_continuous(limits = c(0, 20)) +
      coord_polar() +
      theme_void()
    

    enter image description here