- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to make a polygon radar (spider) chart in Python Matplotlib?
To make a polygon radar (spider) chart in Python, we can take the following steps −
Steps
Set the figure size and adjust the padding between and around the subplots.
Create a Pandas dataframe with sports and values columns.
Create a new figure or activate an existing figure.
Add an 'ax' to the figure as part of a subplot arrangement.
Based on data frame values, get the theta value.
Get the values list of the data frame.
Make a bar plot with theta and values data points.
Fill the area between polygon.
To display the figure, use show() method.
Example
import pandas as pd import matplotlib.pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True df = pd.DataFrame({'sports': ['Strength', 'Speed', 'Power', 'Agility', 'Endurance', 'Analytical Aptitude'], 'values': [7, 8, 6, 10, 8, 9]}) fig = plt.figure() ax = fig.add_subplot(111, projection="polar") theta = np.arange(len(df) + 1) / float(len(df)) * 2 * np.pi values = df['values'].values values = np.append(values, values[0]) l1, = ax.plot(theta, values, color="purple", marker="o", label="Name of values") ax.tick_params(pad=10) ax.fill(theta, values, 'green', alpha=0.3) plt.show()
Output
It will produce the following output −
- Related Articles
- How to use Radar Chart graph in android?
- How to fill an area within a polygon in Python using matplotlib?
- How to plot a bar chart for a list in Python matplotlib?
- How to display stacked bar chart using matplotlib in Python?
- How to plot a nested pie chart in Matplotlib?
- How to create a line chart using Matplotlib?
- How to fill a polygon with a custom hatch in Matplotlib?
- How to plot pie-chart with a single pie highlighted with Python Matplotlib?
- How to add a legend to a Matplotlib pie chart?
- How to display percentage above a bar chart in Matplotlib?
- How to Create a Diverging Stacked Bar Chart in Matplotlib?
- How to make hollow square marks with Matplotlib in Python?
- How to make colorbar orientation horizontal in Python using Matplotlib?
- How to plot a very simple bar chart (Python, Matplotlib) using input *.txt file?
- How to make a star with Polygon class using FabricJS?

Advertisements