Create a special Radial bar chart (race track plot)

587 Views Asked by At

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

2

There are 2 best solutions below

1
Allan Cameron On BEST ANSWER

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

0
Jon Spring On

Here's a start. Are there particular aspects you're trying to replicate? This is a fairly customized format.

df <- data.frame(type = c("on", "ia", "n"),
                 radius = c(2,3,4),
                 value = c(10,21,22))

library(ggplot2); library(ggforce)
ggplot(df) +
  geom_link(aes(x = radius, xend = radius,
                y = 0, yend = value), 
            size = 17, lineend = "round", color = "#bb353c") +
  geom_link(aes(x = radius, xend = radius,
                y = 0, yend = value, color = type), 
            size = 16, lineend = "round") +
  geom_label(aes(radius, y = 30, 
                 label = paste(type, ": ", value)), hjust = 1.8) +
  scale_x_continuous(limits = c(0,4)) +
  scale_y_continuous(limits = c(0, 30)) +
  scale_color_manual(values = c("on" = "#fff7f2", 
                                "ia" = "#f8b68f", 
                                "n" = "#e4593a")) +
  guides(color = "none") +
  coord_polar(theta = "y") + 
  theme_void()

enter image description here