问题
Using the fsmb package I created a simple radar chart. Here is a reproducible example:
#install.packages("fmsb")
library(fmsb)
data <- data.frame(rbind(rep(8,14),
rep(0,14),
c(3,4,4,4,3,4,4,4,4,3,3,3,3,3)))
colnames(data) <- c("biologia", "chemia", "fizyka", "geografia", "historia", "informatyka", "język angielski", "język polski", "matematyka", "muzyka / historia muzyki", "plastyka / sztuka / historia sztuki", "sprawność fizyczna", "technika","wiedza o społeczeństwie" )
radarchart(data,
axistype=1 ,
pcol=rgb(0.2,0.5,0.5,0.5),
pfcol=rgb(0.2,0.5,0.5,0.5),
plwd=4,
cglcol="grey",
cglty=1,
axislabcol="grey",
caxislabels=seq(0,8,2), cglwd=0.8,
vlcex=0.8)
It produces a regular radar chart with a filled polygon.
However, I would prefer the inner area to be more colourful, meaning I would like to colour each internal circle with different colour, leaving the outern area of the polygon blank, so that the differences between categories are better visible to the audience**.
I would be very grateful if anyone has an idea how to achieve this :)
回答1:
You can add some more "data" to create additional polygons aligned with the grid. I made pcol=NA for the additional data so that we just get the polygon with no points. I made some plausible color choices, but note that the polygons all overlap, so the colors add.
## Your data with additional polygons aligned to grid
data <- data.frame(rbind(rep(8,14),
rep(0,14),
rep(4,14), rep(6,14), rep(8,14),
c(3,4,4,4,3,4,4,4,4,3,3,3,3,3)))
## Your color - to avoid repetition
COL1 = rgb(0.2,0.5,0.5,0.5)
## Plot
radarchart(data,
axistype=1 ,
pcol=c(NA, NA, NA, COL1),
pfcol=c("#FF000022", "#FF990022","#FFFF0022", COL1),
plwd=4,
cglcol="grey",
cglty=1,
axislabcol="grey",
caxislabels=seq(0,8,2), cglwd=0.8,
vlcex=0.8)
Update: based on response to answer If you want the interior of the plotted region to be colorful and the exterior to be white, you could add the inner circles instead of the outer circles.
data <- data.frame(rbind(rep(8,14),
rep(0,14),
c(3,4,4,4,3,4,4,4,4,3,3,3,3,3),
rep(2,14), rep(0,14)))
## Plot
radarchart(data,
axistype=1 ,
pcol=c("#FF990088", NA,NA),
pfcol=c("#FF990044","#FFFF0044","#FF000066"),
plwd=4,
cglcol="grey",
cglty=1,
axislabcol="grey",
caxislabels=seq(0,8,2), cglwd=0.8,
vlcex=0.8)
来源:https://stackoverflow.com/questions/51766762/is-it-possible-to-draw-a-radar-chart-in-r-where-each-circle-has-a-different-colo