how to draw Venn Diagram using 6 sets

前端 未结 3 1569
闹比i
闹比i 2021-01-07 04:45

I have a dataset with 6 elements.

An I would like to draw a venn diagram, but with R (Venndiagram library) it\'s limited at 5 elements.

Do you know how can

3条回答
  •  醉梦人生
    2021-01-07 05:43

    I wrote a javascript library a while back that can do this: venn.js . It produces this output on the dataset you gave:

    Output on your data

    Its in javascript, but Kent Russell has provided a htmlwidgets interface to call it from R.

    Code to produce this is:

    // define set sizes and their intersection sizes
    var sets = [
        {sets: ['Ath'], size: 901},
        {sets: ['Fve'], size: 14764},
        {sets: ['Mdm'], size: 19408},
        {sets: ['Pcmm'], size: 17714},
        {sets: ['Pper'], size: 16948},
        {sets: ['Pmum'], size: 17572},
        {sets: ['Ath', 'Fve'], size: 823},
        {sets: ['Ath', 'Mdm'], size: 846},
    
        // need to specfiy the rest of the sets don't overlap
        {sets: ['Ath', 'Pcmm'], size: 0},
        {sets: ['Ath', 'Pper'], size: 0},
        {sets: ['Ath', 'Pmum'], size: 0},
        {sets: ['Fve', 'Mdm'], size: 0},
        {sets: ['Fve', 'Pcmm'], size: 0},
        {sets: ['Fve', 'Pper'], size: 0},
        {sets: ['Fve', 'Pmum'], size: 0},
        {sets: ['Mdm', 'Pcmm'], size: 0},
        {sets: ['Mdm', 'Pper'], size: 0},
        {sets: ['Mdm', 'Pmum'], size: 0},
        {sets: ['Pcmm', 'Pper'], size: 0},
        {sets: ['Pcmm', 'Pmum'], size: 0},
        {sets: ['Pper', 'Pmum'], size: 0},
        ];
    
    // draw the chart in the venn div
    var chart = venn.VennDiagram();
    d3.select("#venn").datum(sets).call(chart);
    

提交回复
热议问题