Skip to content

Commit

Permalink
assets
Browse files Browse the repository at this point in the history
  • Loading branch information
SmirkCao committed Jun 12, 2019
1 parent bc14ffd commit 8c35c42
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
Binary file added CH17/assets/fig_lsa_radar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions CH17/data/cities_ranking.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rank,city,score,A,B,C,D,E,F
1,BJ,93.74,86.98,100.0,95.88,100.0,98.05,82.62
2,SH,88.23,88.96,90.81,76.25,90.25,100.0,75.72
Binary file added CH17/fig_lsa_radar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions CH17/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#! /usr/bin/env python

# Project: Lihang
# Filename: utils
# Date: 6/12/19
# Author: 😏 <smirk dot cao at gmail dot com>
import numpy as np
import matplotlib.pyplot as plt


class Radar(object):
def __init__(self, feas=None, labels=None):
self.feas = feas
self.colors = ['green', 'blue', 'red', 'yellow', 'black']
self.labels = labels

def plot(self, data):
assert self.feas is not None

angles = np.linspace(0.1 * np.pi, 2.1 * np.pi, len(self.feas),
endpoint=False)
angles = np.concatenate((angles, [angles[0]]))

fig = plt.figure(figsize=(5, 5))
ax = fig.add_subplot(111, polar=True)

# ax.legend(loc=[0.25, 1.15], fontsize=18)
ax.set_yticklabels([])
ax.set_thetagrids(angles * 180/np.pi, self.feas, fontsize=12)
ax.grid(True)

for idx, label in enumerate(self.labels):
stats = data[idx]
stats = np.concatenate((stats, [stats[0]]))
ax.plot(angles, stats, '--', linewidth=1,
c=self.colors[idx % len(self.colors)],
label=str(label))
ax.fill(angles, stats,
c=self.colors[idx % len(self.colors)],
alpha=0.25)
plt.legend()
plt.show()
return fig

0 comments on commit 8c35c42

Please sign in to comment.