Circular Bar Plot in Python
Last Updated :
23 Jul, 2025
In this guide, we'll dive into the world of circular bar plots in Python. We'll explore what they are, why they're useful, and how you can create them to add a stylish touch to your data visualization projects.
What is a Circular Bar Plot?
Circular bar plots, also known as radial bar charts or circular stacked bar plots, are a variation of traditional bar plots. Instead of representing data along a horizontal or vertical axis, circular bar plots display data along a circular or radial axis. Each bar extends from the center of the plot outward, with the length of the bar representing the value of the corresponding data point.
Step to Create Circular Bar Plot in Python
Creating a circular bar plot in Python is easier than you might think. Here are the steps you need to follow:
- Step 1: Import libraries: Import the necessary libraries, such as matplotlib, which is a popular plotting library in Python.
- Step 2: Prepare your data: Organize your data into categories and corresponding values that you want to visualize.
- Step 3: Create the plot: Use matplotlib to create a polar plot (subplot_kw=dict(polar=True)) and add bars using the bar() function. Make sure to adjust the angles of the bars appropriately to create a circular layout.
- Step 4: Customize the plot (optional): You can further customize the plot by adding labels, legends, and titles, or changing the color scheme to suit your preferences.
And that's it! With just a few lines of code, you can create stunning circular bar plots to showcase your data in a visually appealing manner.
Circular Bar Plot in Python
Below, are the code examples, of a circular ar plot in Python.
Example 1: Circular Bar Plot Creation Using Matplotlib
In this example, below Python code uses the Matplotlib library to generate a circular bar plot. It imports necessary modules, defines sample data with categories and values, and then creates a subplot with polar projection. Finally, it generates bars on the polar axes corresponding to each category's value, resulting in a circular bar plot visualization.
Python3
import matplotlib.pyplot as plt
import numpy as np
# Sample data
categories = ['Category 1', 'Category 2', 'Category 3', 'Category 4']
values = [20, 35, 30, 25]
# Create a circular bar plot
fig, ax = plt.subplots(subplot_kw=dict(polar=True))
bars = ax.bar(np.arange(len(categories)) * 2 * np.pi / len(categories), values)
plt.show()
Output
fig 1. Output of the above code.Example 2: Customizing a Circular Bar Plot in Matplotlib
In this example, below code uses Matplotlib to create a circular bar plot with customizations. It includes sample data, custom colors, and adds labels to each bar. Additional plot adjustments such as starting angle, direction, and axis limits are applied for improved visualization before displaying the final circular bar plot.
Python3
import matplotlib.pyplot as plt
import numpy as np
# Sample data
categories = ['Category 1', 'Category 2', 'Category 3', 'Category 4']
values = [20, 35, 30, 25]
colors = ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728'] # Custom colors for bars
# Create a circular bar plot
fig, ax = plt.subplots(subplot_kw=dict(polar=True))
bars = ax.bar(np.arange(len(categories)) * 2 * np.pi /
len(categories), values, color=colors, alpha=1)
# Add labels to each bar
for i, (label, angle) in enumerate(zip(categories, np.arange(len(categories)) * 2 * np.pi / len(categories))):
x = angle
y = values[i] + 1 # Adjust height for label placement
ax.text(x, y, label, ha='center', va='center', fontsize=8, color='black')
# Customizing the plot
ax.set_theta_offset(np.pi / 2) # Offset to start the bars from the top
ax.set_theta_direction(-1) # Clockwise direction for bars
# Adjust the y-axis limit for better visualization
ax.set_ylim(0, max(values) + 5)
ax.set_yticks([]) # Hide the y-axis ticks
ax.spines['polar'].set_visible(False) # Hide the polar axis line
plt.show()
Output
fig 2. Creative way of circular bar
Similar Reads
Python - Data visualization tutorial Data visualization is a crucial aspect of data analysis, helping to transform analyzed data into meaningful insights through graphical representations. This comprehensive tutorial will guide you through the fundamentals of data visualization using Python. We'll explore various libraries, including M
7 min read
What is Data Visualization and Why is It Important? Data visualization uses charts, graphs and maps to present information clearly and simply. It turns complex data into visuals that are easy to understand.With large amounts of data in every industry, visualization helps spot patterns and trends quickly, leading to faster and smarter decisions.Common
4 min read
Data Visualization using Matplotlib in Python Matplotlib is a widely-used Python library used for creating static, animated and interactive data visualizations. It is built on the top of NumPy and it can easily handles large datasets for creating various types of plots such as line charts, bar charts, scatter plots, etc. Visualizing Data with P
11 min read
Data Visualization with Seaborn - Python Seaborn is a popular Python library for creating attractive statistical visualizations. Built on Matplotlib and integrated with Pandas, it simplifies complex plots like line charts, heatmaps and violin plots with minimal code.Creating Plots with SeabornSeaborn makes it easy to create clear and infor
9 min read
Data Visualization with Pandas Pandas is a powerful open-source data analysis and manipulation library for Python. The library is particularly well-suited for handling labeled data such as tables with rows and columns. Pandas allows to create various graphs directly from your data using built-in functions. This tutorial covers Pa
6 min read
Plotly for Data Visualization in Python Plotly is an open-source Python library designed to create interactive, visually appealing charts and graphs. It helps users to explore data through features like zooming, additional details and clicking for deeper insights. It handles the interactivity with JavaScript behind the scenes so that we c
12 min read
Data Visualization using Plotnine and ggplot2 in Python Plotnine is a Python data visualization library built on the principles of the Grammar of Graphics, the same philosophy that powers ggplot2 in R. It allows users to create complex plots by layering components such as data, aesthetics and geometric objects.Installing Plotnine in PythonThe plotnine is
6 min read
Introduction to Altair in Python Altair is a declarative statistical visualization library in Python, designed to make it easy to create clear and informative graphics with minimal code. Built on top of Vega-Lite, Altair focuses on simplicity, readability and efficiency, making it a favorite among data scientists and analysts.Why U
4 min read
Python - Data visualization using Bokeh Bokeh is a data visualization library in Python that provides high-performance interactive charts and plots. Bokeh output can be obtained in various mediums like notebook, html and server. It is possible to embed bokeh plots in Django and flask apps. Bokeh provides two visualization interfaces to us
4 min read
Pygal Introduction Python has become one of the most popular programming languages for data science because of its vast collection of libraries. In data science, data visualization plays a crucial role that helps us to make it easier to identify trends, patterns, and outliers in large data sets. Pygal is best suited f
5 min read