How to add text to circos graph from data frame in R

110 Views Asked by At

I have a df that looks like this

X Y
A 3
B 6
C 4
D 9

I would like to plot this in a circos graph using circlize with 4 sections. Each section should have the X axis as the title and within the section it should have the Y axis value. I just want to take the data straight from the df and plot it on a circos graph

1

There are 1 best solutions below

2
Allan Cameron On

It's straightforward to do this in ggplot:

library(ggplot2)

df <- data.frame(x = LETTERS[1:4], y = c(3, 6, 4, 9))

ggplot(df, aes(x = x, y = 1, fill = x)) + 
  geom_col(width = 1, color = "white") +
  geom_text(aes(y = 0.6, label = y), size = 8) +
  coord_polar() +
  theme_void() +
  scale_fill_brewer(palette = "RdYlGn") +
  theme(axis.text.x = element_text(size = 16),
        legend.position = "none")

enter image description here