0

I am creating five radar plots:

library(fmsb)

plottm <- data.frame(clust = 1:5, 
                 Off = c(3,4,2,2,3), 
                 D_Eff = c(5,3,1,3,1), 
                 turn = c(1,1,1,1,1), 
                 Opp_Off = c(5,3,1,5,1), 
                 Opp_Def = c(4,3,3,1,1))
par(mar=c(2,2,2,2))
layout(matrix(1:5, ncol = 5))
lapply(1:5, function(x){
  radarchart(rbind(rep(1,5), rep(5,5), plottm[x,-1]), pfcol = '328', pcol = 'black', title = 'TM', plwd = 3)
})

enter image description here

Currently each plot has the same arguments. I would like to find out how to change the arguments for each plot. I would like to be able to set the title, plot data color and the polygon color for each plot.

If possible I would also like to change the line width for whatever plot has the smallest average plot data. In this case it would be plot five.

The plot data for plot five is c(3,1,1,1,1), The mean is 1.4, which is the smallest.

Any help will be appreciated please let me know if further information is needed.

4

1 回答 1

1

看来你们已经很亲近了。我修改了你的代码:

library(fmsb)

plottm <- data.frame(clust = 1:5, 
                     Off = c(3,4,2,2,3), 
                     D_Eff = c(5,3,1,3,1), 
                     turn = c(1,1,1,1,1), 
                     Opp_Off = c(5,3,1,5,1), 
                     Opp_Def = c(4,3,3,1,1))
par(mar=c(2,2,2,2))
layout(matrix(1:5, ncol = 5))

colours <- c("white", "blue", "orange", "red", "green")
titles <- c("Tm1", "Tm2", "Tm3", "Tm4", "Tm5")
widths <- c(1, 3, 5, 8, 10)
myWidths <- widths[order(rowSums(plottm[, -1]), decreasing= T)]
lapply(1:5, function(x){
  radarchart(rbind(rep(1,5), rep(5,5), 
                   plottm[x,-1]), 
                   pfcol = '328', pcol = colours[x], title = titles[x], plwd = myWidths[x])
})

结果是这样的: 每个图表的单独属性

于 2016-05-05T06:20:18.737 回答