1. Products
  2.   Diagram
  3.   Python
  4.   pyCirclize
 
  

Free Python Library for Circular Visualizations

Open Source Python Diagraming Library for Circular visualization. The Library allows to Create Chord Giagrams, Circular Heatmaps, Circular Bar Plots, Radar Chart and much more.

In the ever-evolving world of data visualization, developers are constantly seeking tools that combine flexibility, ease of use, and powerful features. The pyCirclize library is one such open-source Python tool that enables developers to create stunning circular visualizations with minimal effort. The library is designed for programmatically creating and managing circular visualizations. Inspired by the R package circlize, it enables developers to craft stunning circular plots for genomic, biological, and data visualization applications. The library offers an intuitive API for rendering tracks, heatmaps, links, and more, making it a valuable tool for software developers looking to integrate circular diagrams into their applications.

The pyCirclize library is built on top of Matplotlib, making it highly customizable and compatible with other Python visualization tools. Here are some of the standout features that make pyCirclize a powerful tool for developers, It visualize relationships between entities with customizable links and colors, represent matrices or hierarchical data in a radial layout, display categorical data in a circular format with annotations, create chromosome maps, gene tracks, and synteny plots, built on Matplotlib, allowing developers to customize every aspect of the visualization, seamlessly integrate with other Python libraries and frameworks and so on. Software developers can combine pyCirclize with interactive frameworks like Dash or Streamlit to create web-based apps as well as optimize performance by processing large datasets efficiently before visualization.

Previous Next

Getting Started with pyCirclize

The recommend way to install pyCirclize library is using pypi. Please use the following command for a smooth installation.

Install pyCirclize Library via pypi

pip install pycirclize

Install Py2pUML Library using conda-forge

Install conda-forge package 

Create Chord Diagrams via Python

Chord diagrams are ideal for visualizing relationships between entities. The open source pyCirclize library allows software developers to create chord diagrams with customizable colors, labels, and link styles inside Python applications. The following example demonstrates how to create a chord diagram showing relationships between entities A, B, C, and D using Python commands.

How to Create a Chord Diagram inside Python Apps?

from pycirclize import Circos
import matplotlib.pyplot as plt

# Define relationships
relationships = [
    ("A", "B", 5),
    ("A", "C", 3),
    ("B", "C", 2),
    ("C", "D", 7),
    ("D", "A", 4),
]

# Create Circos instance
circos = Circos(sectors=["A", "B", "C", "D"])

# Add chords
for source, target, value in relationships:
    circos.link((source, 0, 1), (target, 0, 1), color="skyblue", direction=1, ec="black", lw=1)

# Plot
circos.plot()
plt.show()

Circular Heatmaps Support

Circular heatmaps are a great way to represent data in a radial layout. Software developers can use them to display matrices or hierarchical data inside their own applications. The following code example generates a circular heatmap using random data. You can extend this to create an app that allows users to upload their own datasets and customize the heatmap.

How to Create a Circular Heatmap using Python Library?

import numpy as np
from pycirclize import Circos

# Generate random data
np.random.seed(42)
data = np.random.rand(10, 10)

# Create Circos instance
circos = Circos(sectors=np.arange(10))

# Add heatmap
circos.heatmap(data, cmap="viridis")

# Plot
circos.plot()
plt.show()

Circular Bar Plots Creation

Circular bar plots are perfect for visualizing categorical data in a circular format. They are highly customizable and can include annotations. The open source pyCirclize library makes it easy for software developers to create and manage circular bar plot inside Python applications. The following code example creates a circular bar plot showing values for different categories. You can integrate this into an app for data exploration and reporting.

How to Create a Circular Bar Plot using Python Library?

import numpy as np
from pycirclize import Circos

# Generate random data
np.random.seed(42)
data = np.random.rand(10, 10)

# Create Circos instance
circos = Circos(sectors=np.arange(10))

# Add heatmap
circos.heatmap(data, cmap="viridis")

# Plot
circos.plot()
plt.show()

Genomic Data Visualization

The open source pyCirclize library is particularly useful for visualizing genomic data inside Python applications. It provides specialized tools for visualizing genomic data, such as chromosome maps, gene tracks, and synteny plots. Here is a useful code example that allows developers to create circular plot representing chromosomes with their respective sizes.

How to Create Circular Plot Representing Chromosomes using Python?

from pycirclize import Circos

# Define chromosome sizes
genome = {
    "Chr1": 200,
    "Chr2": 150,
    "Chr3": 100,
}

# Create Circos instance
circos = Circos(sectors=genome)

# Add chromosome tracks
for sector in circos.sectors:
    sector.text(f"{sector.name}", size=15)
    sector.xticks_by_interval(50, label_size=10)

# Plot
circos.plot()
plt.show()