I try to generate a complexe radar with VEDO in python. I found a example code from stackoverflow and I want to modify it.
My goal is to generate a radar multiple scale on each axes. Here is the code I have:
import numpy as np
import pylab as pl
from matplotlib import pyplot as plt
class Radar(object):
def __init__(self, fig, titles, labels, rect=None):
if rect is None:
rect = [0.05, 0.05, 0.95, 0.95]
self.n = len(titles)
self.angles = np.arange(90, 90+360, 360.0/self.n)
self.angles = [a % 360 for a in self.angles]
self.axes = [fig.add_axes(rect, projection="polar", label="axes%d" % i)
for i in range(self.n)]
self.ax = self.axes[0]
self.ax.set_thetagrids(self.angles, labels=titles, fontsize=14)
for ax in self.axes[0:]:
ax.patch.set_visible(False)
ax.grid("off")
ax.xaxis.set_visible(False)
index = 0
for ax, angle, label in zip(self.axes, self.angles, labels):
ax.set_rgrids(range(1, label.__len__()+1), angle=angle, labels=label)
ax.spines["polar"].set_visible(True)
ax.set_ylim(0, label.__len__())
index+=1
def plot(self, values, *args, **kw):
angle = np.deg2rad(np.r_[self.angles, self.angles[0]])
values = np.r_[values, values[0]]
self.ax.plot(angle, values, *args, **kw)
fig = pl.figure(figsize=(6, 6))
titles = list("ABCDE")
labels = [
list("abc"), list("12345"), list("uvwxy"),
["one", "two", "three", "four", "five"],
list("jklmn")
]
radar = Radar(fig, titles, labels)
radar.plot([2,2,2,2,2], "-", lw=2, color="b", alpha=0.4, label="first")
radar.plot([2.3, 2, 3, 3, 2],"-", lw=2, color="r", alpha=0.4, label="second")
radar.plot([3, 4, 3, 4, 2], "-", lw=2, color="g", alpha=0.4, label="third")
radar.ax.legend()
plt.show()
And the result: enter image description here
The blue line is not following the good scale on each axe. It seems to correspond to my first axe I think.