Skip to content

OpenChord is a Python library for creating chord diagrams.

License

Notifications You must be signed in to change notification settings

pke1029/open-chord

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenChord

OpenChord is a Python library I am developing to plot beautiful chord diagrams for visualising networks and graphs. OpenChord uses the drawsvg library and can display figures in a Jupyter notebook or Jupyter lab. Other libraries for drawing chord diagram includes PlotAPI (paid), Bokeh (visible moire artifact), and Plotly (tedious).

Installation

OpenChord is now on PyPI.org! Install using the command

pip install openchord

Usage

The chord diagram is defined by an adjacency matricies (possibly non-symmetric)

import openchord as ocd

adjacency_matrix = [[ 3, 18,  9,  0, 23],
                    [18,  0, 12,  5, 29],
                    [ 9, 12,  0, 27, 10],
                    [ 0,  5, 27,  0,  0],
                    [23, 29, 10,  0,  0]]
labels = ['Emma', 'Isabella', 'Ava', 'Olivia', 'Sophia']

fig = ocd.Chord(adjacency_matrix, labels)
fig.show()

Color can be changed like so

fig.colormap = ['#636EFA', '#EF553B', '#00CC96', '#AB63FA', '#FFA15A', '#19D3F3', '#FF6692', '#B6E880', '#FF97FF', '#FECB52']
fig.show()

You can export the figure as an .svg file and open it in a vector graphics software such as Inkscape

fig.save_svg("figure.svg")

Chord diagram using OpenChord

More tutorials and examples

I wrote a few more tutorials available via the link below and in the /examples directory. Feel free to download them and run it yourself.

  1. Quick Start

    • First chord diagram
    • Radius
    • Padding
    • Font size and font family
    • Colormap
    • Background color and transparancy
  2. The Logo (The text is not centered vertically when viewed on GitHub)

    • Rotation
    • Custom plot area
    • Gradient style
    • Arc thickness
    • Text position
    • Gap size
    • Ribbon gap
    • Ribbon stiffness
    • Save as SVG

About

OpenChord is a Python library for creating chord diagrams.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages