R 中两端重叠的和弦图()
我正在尝试使用 R 中的 circlize 包中的 chordDiagram() 函数在 R 中生成和弦图的修改版本。
假设我们有这个玩具示例(至于包的文档):
require(circlize)
df = expand.grid(letters[1:3], LETTERS[1:4])
df$value = 1
df$value2 = 3
chordDiagram(df[, 1:3])
输出将非常简单:
现在,问题是:让我们假设我需要使两个“端”重叠来表示交叉点,例如,从 b-->A 出发的色带和从 a-->A 出发的色带,因此它们在同一扇区中结束,彼此“合并”(如下图所示)。
这可能吗?我在文档中没有找到任何示例,也无法通过调整选项来执行此任务。
希望我说清楚了。感谢您的任何尝试。
I am trying to produce a modified version of a Chord Diagram in R using the chordDiagram()
function in the circlize
package in R.
Suppose we have this toy example (as for the documentation of the package):
require(circlize)
df = expand.grid(letters[1:3], LETTERS[1:4])
df$value = 1
df$value2 = 3
chordDiagram(df[, 1:3])
The output will be pretty straightforward:
Now, the problem is: let's suppose that I need to make two "ends" overlap to represent an intersection, for example, the ribbon going from b-->A and the ribbon going from a-->A, so that they end in the same sector "merging" each other (such as in the figure below).
Is that possible? I didn't find any example in the documentation nor I was able to perform this task by tweaking the options.
Hope that I made myself clear. Thank you for any try.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我理解正确的话,你想在图中制作重叠的部分。例如
S3 -> E2
和S2 -> E2。您创建一个具有格式的矩阵,以便您在图中获得重叠的路径。我将用以下代码为您提供一个示例:
首先创建一个在 S 和 E 之间具有不同值的连接的矩阵:
接下来创建一个数据框,其格式为列的格式,其中字符从到另一个字符,并带有值以检查模式更多轻松:
使用
mat
绘制输出:如您所见,
S3 -> 的路径存在一些重叠。 E2
和S2 -> E2。
If I understand you correctly, you want to make overlapping parts in the diagram. So for example
S3 -> E2
andS2 -> E2
. You create a matrix which has a format so that you get overlapping paths in the diagram. I will give you an example with the following code:First create a matrix with connection between S and E with different values:
Next create a dataframe which has a format of columns with character from to another character with values to check what the patterns are more easily:
Plot the output using
mat
:As you can see, there is some overlap in the paths of
S3 -> E2
andS2 -> E2
.