r - Using geom_path from ggplot library -


i have 12 variables, m1, m2, ..., m12, compute statistic x.

 df = data.frame(model = factor(paste("m", 1:28, sep = ""), levels=paste("m", 1:28, sep = "")), x = runif(28, 1, 1.05))   levels = seq(0.8, 1.2, 0.05) 

i plot data follows:

enter image description here

each circle (contour) represents level of statistic "x". 3 blue lines represent 3 different scenarios.

the dataframe included in example represents 1 scenario. blue line join values of models m1 m28 specific scenario.

i tried following:

 ggplot(data=df, aes(x=model, y=x, group=1)) +     geom_line() + coord_polar() +     scale_y_continuous(limits=range(levels), breaks=levels, labels=levels) +    theme(axis.text.y = element_blank(), axis.ticks = element_blank(), axis.title.x = element_blank(), axis.title.y = element_blank()) 

however, disconnected path (between m28 , m1)

enter image description here

then, replicated first row , placed @ bottom of dataframe (see below), , used geom_path() instead of geom_line(), didn't result looking for:

 ## replicating first row (model1) , placing @ end of dataframe  df = rbind(df, df[1,])   ## using geom_path()   ggplot(data=df, aes(x=model, y=lg, group=1)) +     geom_path() + coord_polar() +     scale_y_continuous(limits=range(levels), breaks=levels, labels=levels) +    theme(axis.text.y = element_blank(), axis.ticks = element_blank(), axis.title.x =  element_blank(), axis.title.y = element_blank()) 

enter image description here

could please me achieve result looking for? appreciated. thanks!

you have use geom_polygon closed paths:

library(ggplot2) ggplot(data=df, aes(x=model, y=x, group=1)) +    geom_polygon(fill = na, colour = "black") +    coord_polar() +    scale_y_continuous(limits=range(levels), breaks=levels, labels=levels) +   theme(axis.text.y = element_blank(), axis.ticks = element_blank(),          axis.title.x = element_blank(), axis.title.y = element_blank()) 

enter image description here


Comments

Popular posts from this blog

c# - OpenXML hanging while writing elements -

php - regexp cyrillic filename not matches -

java - IntelliJ - No such instance method -