Skip to content
Advertisement

How can I turn my DataFrame into a Radar Chart using Python?

I have a DataFrame I want to turn into a Radar Chart. The DataFrame looks like this when it’s ran…

JavaScript

I repurposed some code I found on another Stack Overflow question pertaining to Pandas and Radar Charts and it works for the most part except I can’t get the values of Col B to align properly within the chart. Below is the code I’m using…

JavaScript

And the chart looks like this…

enter image description here

Since I’m still such a newbie at Python I have no idea what I’m doing wrong here. I’ve tried many things to modify the code including eliminating the first two lines of code and simply putting… points = df['Col B'] instead but all it did was erase the names around the circle while leaving everything else the same. What am I doing wrong here?

Also how can I fill the area inside the theta with a light green? I tried l1, = ax.fill(theta, facecolor = 'g', alpha=0.25) below the l1, = ax.plot(theta, color="C2", marker="o", label="Name of Col B") line, but it gave me this error AttributeError: 'Polygon' object has no attribute 'get_data' and I can’t seem to work it out.

Any help is much appreciated!

Advertisement

Answer

Here is an adaption of the code at this example to get you started with the way your data is stored.

JavaScript

resulting radar plot

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement