版块导航
正在加载中...
客户端APP下载
登录
注册
帖子
帖子
用户
本版
应《网络安全法》要求,自2017年10月1日起,未进行实名认证将不得使用互联网跟帖服务。为保障您的帐号能够正常使用,请尽快对帐号进行手机号验证,感谢您的理解与支持!
24小时热门版块排行榜
>
论坛更新日志
(3887)
>
博后之家
(196)
>
导师招生
(179)
>
论文投稿
(175)
>
文献求助
(124)
>
虫友互识
(106)
>
有机交流
(80)
>
硕博家园
(73)
>
招聘信息布告栏
(41)
>
休闲灌水
(24)
>
学术会议
(21)
>
考博
(21)
>
找工作
(16)
>
考研
(11)
>
基金申请
(8)
>
教师之家
(8)
小木虫论坛-学术科研互动平台
»
计算模拟区
»
程序语言
»
Shell&Perl
»
python matplotlib 库怎么绘制蜘蛛图或雷达图?
5
1/1
返回列表
查看: 3017 | 回复: 68
只看楼主
@他人
存档
新回复提醒
(忽略)
收藏
在APP中查看
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖
zxx4477
金虫
(正式写手)
应助: 2
(幼儿园)
金币: 1288.7
帖子: 694
在线: 422.4小时
虫号: 2697314
已领完
python matplotlib 库怎么绘制蜘蛛图或雷达图?
领取红包
(小木虫手机app专属红包)
扫一扫,下载小木虫客户端
如题,请高手指点
发自小木虫Android客户端
回复此楼
» 猜你喜欢
各位大神,目前国内有哪些比较好用的逆合成软件?
已经有15人回复
国社科系统bug了,是不是要放榜了?
已经有10人回复
现代”学阀”该如何界定
已经有9人回复
课题组招2027级博士 上海工程技术大学 激光智能制造方向
已经有4人回复
上海工程技术大学 激光智能制造课题组 2027级博士研究生招生
已经有3人回复
上海工程技术大学激光智能制造课题组|2027级博士研究生招生公告
已经有11人回复
申博发邮件
已经有11人回复
我的奶奶
已经有3人回复
高级回复
» 抢金币啦!回帖就可以得到:
查看全部散金贴
2027年生物医学、农业与可持续发展国际会议(BASD 2027)
+
1
/910
2027年计算机视觉、设计与非遗文化传播国际会议(CVDC 2027)
+
1
/876
大连理工大学大连市复杂工业场景具身智能重点实验室科研助理招聘启事
+
2
/164
大连理工大学控制科学与工程学院欧勇盛教授课题组2026年科研助理招聘启事
+
2
/164
澳门大学孙鹏展博士课题组招收全奖博士研究生1名
+
2
/94
韩国全北国立大学禽病研究所博士研究生招生简章
+
2
/60
求助邢其毅第四版基础有机化学PDF版
+
1
/32
加拿大UBC博士后招聘|人工智能 × 电池
+
1
/18
加拿大UBC博士/博士后招聘|人工智能 × 电池
+
1
/16
【推免招生】招收材料、化工、环境、冶金类推免生
+
1
/9
【征稿】Springer Nature热电专题 Discover Materials / Discover Chemistry
+
1
/9
加拿大UBC博士后招聘|人工智能 × 电池
+
1
/9
今天爱思唯尔的官网是不是被黑客攻击了
+
1
/5
巨噬细胞空间 Marker 及原位检测技术的研究应用
+
1
/5
澳大利亚 ARC DECRA/Future Fellow团队招收力学、机械、土木等方向项目全奖博士生
+
1
/3
欢迎推荐和自荐硕士推免生和硕博连读推免生!中国林业科学研究院草学、生态学方向。
+
1
/2
新药研发为什么这么难?多因子检测如何成为创新药的"数据引擎"
+
1
/1
院士领衔,ICBMBA生物功能材料与生物医学应用会议诚邀学者加入!
+
1
/1
环境控制与良率强绑定:手套箱的工程化进阶路径
+
1
/1
肺泡灌洗液多因子检测技术及样本规范化处理策略
+
1
/1
1楼
2016-12-08 09:19:56
已阅
回复此楼
关注TA
给TA发消息
送TA红花
TA的回帖
FMStation
至尊木虫
(知名作家)
应助: 591
(博士)
贵宾: 0.03
金币: 18769.2
帖子: 8891
在线: 1498.1小时
虫号: 2400059
★
小木虫: 金币+0.5, 给个红包,谢谢回帖
http://matplotlib.org/examples/api/radar_chart.html
CODE:
"""
Example of creating a radar chart (a.k.a. a spider or star chart) [1]_.
Although this example allows a frame of either 'circle' or 'polygon', polygon
frames don't have proper gridlines (the lines are circles instead of polygons).
It's possible to get a polygon grid by setting GRIDLINE_INTERPOLATION_STEPS in
matplotlib.axis to the desired number of vertices, but the orientation of the
polygon is not aligned with the radial axes.
.. [1] http://en.wikipedia.org/wiki/Radar_chart
"""
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.path import Path
from matplotlib.spines import Spine
from matplotlib.projections.polar import PolarAxes
from matplotlib.projections import register_projection
def radar_factory(num_vars, frame='circle'):
"""Create a radar chart with `num_vars` axes.
This function creates a RadarAxes projection and registers it.
Parameters
----------
num_vars : int
Number of variables for radar chart.
frame : {'circle' | 'polygon'}
Shape of frame surrounding axes.
"""
# calculate evenly-spaced axis angles
theta = np.linspace(0, 2*np.pi, num_vars, endpoint=False)
# rotate theta such that the first axis is at the top
theta += np.pi/2
def draw_poly_patch(self):
verts = unit_poly_verts(theta)
return plt.Polygon(verts, closed=True, edgecolor='k')
def draw_circle_patch(self):
# unit circle centered on (0.5, 0.5)
return plt.Circle((0.5, 0.5), 0.5)
patch_dict = {'polygon': draw_poly_patch, 'circle': draw_circle_patch}
if frame not in patch_dict:
raise ValueError('unknown value for `frame`: %s' % frame)
class RadarAxes(PolarAxes):
name = 'radar'
# use 1 line segment to connect specified points
RESOLUTION = 1
# define draw_frame method
draw_patch = patch_dict[frame]
def fill(self, *args, **kwargs):
"""Override fill so that line is closed by default"""
closed = kwargs.pop('closed', True)
return super(RadarAxes, self).fill(closed=closed, *args, **kwargs)
def plot(self, *args, **kwargs):
"""Override plot so that line is closed by default"""
lines = super(RadarAxes, self).plot(*args, **kwargs)
for line in lines:
self._close_line(line)
def _close_line(self, line):
x, y = line.get_data()
# FIXME: markers at x[0], y[0] get doubled-up
if x[0] != x[-1]:
x = np.concatenate((x, [x[0]]))
y = np.concatenate((y, [y[0]]))
line.set_data(x, y)
def set_varlabels(self, labels):
self.set_thetagrids(np.degrees(theta), labels)
def _gen_axes_patch(self):
return self.draw_patch()
def _gen_axes_spines(self):
if frame == 'circle':
return PolarAxes._gen_axes_spines(self)
# The following is a hack to get the spines (i.e. the axes frame)
# to draw correctly for a polygon frame.
# spine_type must be 'left', 'right', 'top', 'bottom', or `circle`.
spine_type = 'circle'
verts = unit_poly_verts(theta)
# close off polygon by repeating first vertex
verts.append(verts[0])
path = Path(verts)
spine = Spine(self, spine_type, path)
spine.set_transform(self.transAxes)
return {'polar': spine}
register_projection(RadarAxes)
return theta
def unit_poly_verts(theta):
"""Return vertices of polygon for subplot axes.
This polygon is circumscribed by a unit circle centered at (0.5, 0.5)
"""
x0, y0, r = [0.5] * 3
verts = [(r*np.cos(t) + x0, r*np.sin(t) + y0) for t in theta]
return verts
def example_data():
# The following data is from the Denver Aerosol Sources and Health study.
# See doi:10.1016/j.atmosenv.2008.12.017
#
# The data are pollution source profile estimates for five modeled
# pollution sources (e.g., cars, wood-burning, etc) that emit 7-9 chemical
# species. The radar charts are experimented with here to see if we can
# nicely visualize how the modeled source profiles change across four
# scenarios:
# 1) No gas-phase species present, just seven particulate counts on
# Sulfate
# Nitrate
# Elemental Carbon (EC)
# Organic Carbon fraction 1 (OC)
# Organic Carbon fraction 2 (OC2)
# Organic Carbon fraction 3 (OC3)
# Pyrolized Organic Carbon (OP)
# 2)Inclusion of gas-phase specie carbon monoxide (CO)
# 3)Inclusion of gas-phase specie ozone (O3).
# 4)Inclusion of both gas-phase speciesis present...
data = [
['Sulfate', 'Nitrate', 'EC', 'OC1', 'OC2', 'OC3', 'OP', 'CO', 'O3'],
('Basecase', [
[0.88, 0.01, 0.03, 0.03, 0.00, 0.06, 0.01, 0.00, 0.00],
[0.07, 0.95, 0.04, 0.05, 0.00, 0.02, 0.01, 0.00, 0.00],
[0.01, 0.02, 0.85, 0.19, 0.05, 0.10, 0.00, 0.00, 0.00],
[0.02, 0.01, 0.07, 0.01, 0.21, 0.12, 0.98, 0.00, 0.00],
[0.01, 0.01, 0.02, 0.71, 0.74, 0.70, 0.00, 0.00, 0.00]]),
('With CO', [
[0.88, 0.02, 0.02, 0.02, 0.00, 0.05, 0.00, 0.05, 0.00],
[0.08, 0.94, 0.04, 0.02, 0.00, 0.01, 0.12, 0.04, 0.00],
[0.01, 0.01, 0.79, 0.10, 0.00, 0.05, 0.00, 0.31, 0.00],
[0.00, 0.02, 0.03, 0.38, 0.31, 0.31, 0.00, 0.59, 0.00],
[0.02, 0.02, 0.11, 0.47, 0.69, 0.58, 0.88, 0.00, 0.00]]),
('With O3', [
[0.89, 0.01, 0.07, 0.00, 0.00, 0.05, 0.00, 0.00, 0.03],
[0.07, 0.95, 0.05, 0.04, 0.00, 0.02, 0.12, 0.00, 0.00],
[0.01, 0.02, 0.86, 0.27, 0.16, 0.19, 0.00, 0.00, 0.00],
[0.01, 0.03, 0.00, 0.32, 0.29, 0.27, 0.00, 0.00, 0.95],
[0.02, 0.00, 0.03, 0.37, 0.56, 0.47, 0.87, 0.00, 0.00]]),
('CO & O3', [
[0.87, 0.01, 0.08, 0.00, 0.00, 0.04, 0.00, 0.00, 0.01],
[0.09, 0.95, 0.02, 0.03, 0.00, 0.01, 0.13, 0.06, 0.00],
[0.01, 0.02, 0.71, 0.24, 0.13, 0.16, 0.00, 0.50, 0.00],
[0.01, 0.03, 0.00, 0.28, 0.24, 0.23, 0.00, 0.44, 0.88],
[0.02, 0.00, 0.18, 0.45, 0.64, 0.55, 0.86, 0.00, 0.16]])
]
return data
if __name__ == '__main__':
N = 9
theta = radar_factory(N, frame='polygon')
data = example_data()
spoke_labels = data.pop(0)
fig = plt.figure(figsize=(9, 9))
fig.subplots_adjust(wspace=0.25, hspace=0.20, top=0.85, bottom=0.05)
colors = ['b', 'r', 'g', 'm', 'y']
# Plot the four cases from the example data on separate axes
for n, (title, case_data) in enumerate(data):
ax = fig.add_subplot(2, 2, n + 1, projection='radar')
plt.rgrids([0.2, 0.4, 0.6, 0.8])
ax.set_title(title, weight='bold', size='medium', position=(0.5, 1.1),
horizontalalignment='center', verticalalignment='center')
for d, color in zip(case_data, colors):
ax.plot(theta, d, color=color)
ax.fill(theta, d, facecolor=color, alpha=0.25)
ax.set_varlabels(spoke_labels)
# add legend relative to top-left plot
plt.subplot(2, 2, 1)
labels = ('Factor 1', 'Factor 2', 'Factor 3', 'Factor 4', 'Factor 5')
legend = plt.legend(labels, loc=(0.9, .95), labelspacing=0.1)
plt.setp(legend.get_texts(), fontsize='small')
plt.figtext(0.5, 0.965, '5-Factor Solution Profiles Across Four Scenarios',
ha='center', color='black', weight='bold', size='large')
plt.show()
赞
一下
(1人)
回复此楼
高级回复
69楼
2016-12-12 11:08:46
已阅
回复此楼
关注TA
给TA发消息
送TA红花
TA的回帖
查看全部 69 个回答
简单回复
xyzzhlyf
2楼
2016-12-08 09:20
回复
zxx4477(金币+1): 谢谢参与
已获得
1
个金币
发自小木虫IOS客户端
chuyp
3楼
2016-12-08 09:20
回复
zxx4477(金币+1): 谢谢参与
已获得
1
个金币
发自小木虫Android客户端
帘卷西风瘦
4楼
2016-12-08 09:20
回复
zxx4477(金币+1): 谢谢参与
已获得
1
个金币
发自小木虫Android客户端
2015211816
5楼
2016-12-08 09:20
回复
zxx4477(金币+1): 谢谢参与
已获得
1
个金币
发自小木虫Android客户端
zz逐风
6楼
2016-12-08 09:20
回复
zxx4477(金币+2): 谢谢参与
已获得
2
个金币
发自小木虫IOS客户端
小懒萧萧
7楼
2016-12-08 09:20
回复
zxx4477(金币+2): 谢谢参与
已获得
2
个金币
发自小木虫IOS客户端
西北东南1316
8楼
2016-12-08 09:20
回复
zxx4477(金币+1): 谢谢参与
已获得
1
个金币
发自小木虫IOS客户端
讽诵
9楼
2016-12-08 09:20
回复
zxx4477(金币+1): 谢谢参与
已获得
1
个金币
发自小木虫Android客户端
天乐小龙
10楼
2016-12-08 09:20
回复
zxx4477(金币+2): 谢谢参与
已获得
2
个金币
发自小木虫IOS客户端
哭泣的二向箔
11楼
2016-12-08 09:20
回复
zxx4477(金币+2): 谢谢参与
已获得
2
个金币
发自小木虫Android客户端
ammonup
12楼
2016-12-08 09:20
回复
zxx4477(金币+2): 谢谢参与
已获得
2
个金币
发自小木虫Android客户端
datouson
13楼
2016-12-08 09:20
回复
zxx4477(金币+1): 谢谢参与
已获得
1
个金币
发自小木虫Android客户端
WWSDDU
14楼
2016-12-08 09:20
回复
zxx4477(金币+1): 谢谢参与
已获得
1
个金币
发自小木虫Android客户端
查看全部 69 个回答
如果回帖内容含有宣传信息,请如实选中。否则帐号将被全论坛禁言
普通表情
龙
兔
虎
猫
高级回复
(可上传附件)
百度网盘
|
360云盘
|
千易网盘
|
华为网盘
在新窗口页面中打开自己喜欢的网盘网站,将文件上传后,然后将下载链接复制到帖子内容中就可以了。
信息提示
关闭
请填处理意见
关闭
确定