Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R Circlize Chord Diagram Output

Tags:

r

I am new to the circlize package in R. However, the output from my first chord diagram looks oval-shaped rather than a circle as shown in the documentation examples. What can I do? Code and image below.

    #random matrix, for illustration
    mat
       E1 E2 E3 E4 E5 E6
    S1  8 13 18  6 11 14
    S2 10 12  1  3  5  7
    S3  2 16  4 17  9 15
    chordDiagram(mat)

This is my output :

This is my output

This is what I want :

This is what I want

like image 460
Juan Mier Avatar asked Mar 12 '23 09:03

Juan Mier


1 Answers

You need to force a squared plotting region using par(pty="s") :

library(circlize)

mat <- read.table(text=
",E1,E2,E3,E4,E5,E6
S1,8,13,18,6,11,14
S2,10,12,1,3,5,7
S3,2,16,4,17,9,15",header=TRUE,sep=",",row.names=1)
par(pty="s")
chordDiagram(as.matrix(mat))

diagram

like image 123
digEmAll Avatar answered Mar 23 '23 06:03

digEmAll