r - 使用 R 填充圆圈中的 9 个区域

标签 r plot

寻找一种方法来填充该圆的每个不同部分,用于可视化视网膜不同部分的厚度。使用 Excel 中的数据,如果变量为 1,则不同部分将突出显示(如果变量为 ,则不会突出显示)。

library(plotrix)
plot(1,1,col="white",bty="n", xaxt="n", yaxt="n", xlab="1",ann=FALSE)
draw.circle(1,1,0.3)
draw.circle(1,1,.15)
draw.circle(1,1,.05)
arrows(0.77787,0.77787, 0.962644661,0.962644661,length=0)
arrows(1.037355339,1.037355339, 1.22213,1.22213, length=0)
arrows(0.77787,1.22213,0.962644661,1.037355339,length=0)
arrows(1.037355339,0.962644661,1.22213,0.77787,length=0)

enter image description here

最佳答案

您可以使用 piedraw.circle 的组合来完成此操作:

library(plotrix)
library(RColorBrewer)

cols <- brewer.pal(9, 'Set3')

pie(rep(1, 4), col=cols[1:4], init.angle=45, radius=1, labels='')
par(new=TRUE)
pie(rep(1, 4), col=cols[5:8], init.angle=45, radius=0.5, labels='')
draw.circle(0, 0, 0.166, col=cols[9])

retina

根据需要设置col以填充(或不填充)各个部分,例如:

pie(rep(1, 4), col=c(0, 0, 'gray80', 0), init.angle=45, radius=1, labels='')
par(new=TRUE)
pie(rep(1, 4), col=rep(0, 4), init.angle=45, radius=0.5, labels='')
draw.circle(0, 0, 0.166, col='gray80')

retina2

关于r - 使用 R 填充圆圈中的 9 个区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26989344/

相关文章:

python - python 中 rnorm 的模拟

javascript - R 传单 : Add a Range Slider to Filter Markers without Shiny

r - 动态创建的绘图不会与四开本中的节标题交替

r - 如何使用 R 在基于代理的建模中管理内存

r - 在 termux 上加载库 "libicuuc.so.63"时出错

image - 尝试将散点图的可写图像复制到剪贴板时出现 Javafx 剪贴板 com 错误

r - 使用 Polar 方法模拟随机变量

r - 具有显着差异和相互作用的条形图?

matlab - 如何在 Matlab 中向线图添加箭头?

r - 从结构化文本文件中提取信息以在 R 中创建数据框