r - Polar coordinate / circular layout for the whole facet_grid -


i have dataset values 2 ordered discrete factors, corresponding continuous values. (random sample generated below)

randomdata = expand.grid(1:5, 1:100)    # 2 discrete variables colnames(randomdata) = c("index1", "index2")  randomdata$z = runif(nrow(randomdata))   # measured value   ggplot(randomdata, aes(x = 1, y = z)) +    geom_bar(stat = "identity") +    facet_grid(index1 ~ index2) +    theme_minimal() 

enter image description here

i trying wrap whole grid circular / polar layout, such 1 displayed below, using bar plots generated.

the first plot desired output (manipulated photo editing tool first facet plot). second plot output of blog post: http://chrisladroue.com/2012/02/polar-histogram-pretty-and-useful/). however, contains single "row".

enter image description here enter image description here

i cant figure out way that. when try add coord_polar(), bar plots affected , not facet.

i don't think can arrange facets in circle, can cheat changing x , y variables , using coord_polar().

library(ggplot2) library(dplyr) d <- rbind(     mutate(randomdata, col = "dark"),      mutate(randomdata, col = "blank", z = 1 - z) ) %>% arrange(d, index2, index1, col)  ggplot(d, aes(x = factor(index2), y = z)) +     geom_bar(aes(fill = col), stat = "identity", position = "stack") +     scale_fill_manual(values = c(blank = "white", dark = "black")) +     coord_polar() +     theme_minimal() +     guides(fill = false) 

enter image description here

you have adapt quite bit fit original data set idea - add rows values (1 - z) , use them stack bars


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -