谁能帮助我解决如何在R中创建穿孔卡图(不使用ggplot)的问题?

就像python中制作的this one一样:

最佳答案

黑色边框在原始图形上看起来不错。可以使用symbols()复制它。添加sqrt((pctable$value / max(pctable$value)) / pi)以确保值与符号的表面成比例,而不是与符号的半径成比例。

pctable <- data.frame(expand.grid(weekday=c("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"),
                              day=1:22), value=abs(rnorm(nrow(pctable), 20, 30)))

par(list(las=1, mar=c(6,6,1,1), mgp=c(4.5,1,0)))

bubble.size <- sqrt((pctable$value / max(pctable$value)) / pi)
symbols(pctable$day, pctable$weekday, circles=bubble.size,
    inches=.2, fg="black", bg="blue", yaxt="n", xaxt="n", xlab="Day", ylab="Weekday")
axis(1, at=1:22, labels=c(1:22))
axis(2, at=1:7,labels=rev(c("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday")), cex.axis=0.7)

关于r - R中的打洞卡图,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20044359/

10-12 16:30