本文介绍了(R)中围绕圆圈缠绕/弯曲文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 有没有机会写出围绕圆圈包裹的文字?我的意思是这样的: 解决方案您也可以在 plotrix 包中尝试 arctext : $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $' y = 0,xlim = c(-2,2),ylim = c(-2,2)) draw.circle(x = 0,y = 0,radius = 1) $ btexttext(x =wrap some text,center = c(0,0),radius = 1.1,middle = pi / 2) arctext(x =counterclockwise, center = c(0,0),radius = 1.1,middle = 5 * pi / 4,顺时针= FALSE,cex = 1.5) arctext(x =更小&拉伸 c(0,0),radius = 1.1,middle = 2 * pi, cex = 0.8,stretch = 1.2) 为了获得更大的定制机会(轻描淡写,看到美好的景象tes),你可以看看 circlize 包。通过在 circos.text 中设置 facing =bending,文字环绕一圈。 library(circlize) #创建一些角度,标签及其相应的因子# deg lab 因子 #初始化图 circos.par(gap.degree = 10) circos.initialize(因子=因子, xlim = c(0,1)) circos.trackPlotRegion(ylim = c(0,1)) #将文本添加到每个扇区 lapply(因子,函数deg){ circos.updatePlotRegion(sector.index = deg,bg.col =red) circos.text(x = 0.5,y = 0.5,labels = as.character(deg), ) circos.clear() 更新: 在 circlize version 0.2.1 , circos.text 有两个新选项: bending.inside 与原始弯曲和 bending.outside (见小插曲)。因此,使用 bending.outside 可以很容易地打开剧情下半部分的文本: $ $ $ $ circos.initialize(因子=因子,xlim = c(0,1)) circos.trackPlotRegion(ylim = c (0,1)) lapply(因子[1:3],函数(deg){ circos.updatePlotRegion(sector.index = deg,bg.col =red)) circos.text(x = 0.5,y = 0.5,labels = as.character(deg),facing =bending.outside)}) lapply(factor [4:6],函数(deg){ circos.updatePlotRegion(sector.index = deg,bg.col =red) circos.text(x = 0.5,y = 0.5,labels = as.character(deg),facing =bending.inside)}) circos.clear() Is there any chance to write text which is "wrapped" around the circle? I mean something like this: 解决方案 You may also try arctext in plotrix package:library(plotrix)# set up a plot with a circleplot(x = 0, y = 0, xlim = c(-2, 2), ylim = c(-2, 2))draw.circle(x = 0, y = 0, radius = 1)# add textarctext(x = "wrap some text", center = c(0, 0), radius = 1.1, middle = pi/2)arctext(x = "counterclockwise", center = c(0, 0), radius = 1.1, middle = 5*pi/4, clockwise = FALSE, cex = 1.5)arctext(x = "smaller & stretched", center = c(0, 0), radius = 1.1, middle = 2*pi , cex = 0.8, stretch = 1.2)For greater opportunities of customization (an understatement; see the nice vignettes), you may have a look at circlize package. By setting facing = "bending" in circos.text, the text wraps around a circle.library(circlize)# create some angles, labels and their corresponding factors# which determine the sectors deg <- seq(from = 0, to = 300, by = 60)lab <- paste("some text", deg, "-", deg + 60) factors <- factor(lab, levels = lab)# initialize plotcircos.par(gap.degree = 10)circos.initialize(factors = factors, xlim = c(0, 1))circos.trackPlotRegion(ylim = c(0, 1))# add text to each sector lapply(factors, function(deg){ circos.updatePlotRegion(sector.index = deg, bg.col = "red")circos.text(x = 0.5, y = 0.5, labels = as.character(deg), facing = "bending")})circos.clear()Update:In circlize version 0.2.1, circos.text has two new options: bending.inside which is identical to original bending and bending.outside (see fig 11 in the vignette). Thus, it is easy to turn the text in the bottom half of the plot using bending.outside:circos.par(gap.degree = 10)circos.initialize(factors = factors, xlim = c(0, 1))circos.trackPlotRegion(ylim = c(0, 1))lapply(factors[1:3], function(deg){ circos.updatePlotRegion(sector.index = deg, bg.col = "red") circos.text(x = 0.5, y = 0.5, labels = as.character(deg), facing = "bending.outside")})lapply(factors[4:6], function(deg){ circos.updatePlotRegion(sector.index = deg, bg.col = "red") circos.text(x = 0.5, y = 0.5, labels = as.character(deg), facing = "bending.inside")})circos.clear() 这篇关于(R)中围绕圆圈缠绕/弯曲文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-26 17:22