matplotlib实例笔记
下面的图型是在一幅画布上建立的四个球员相关数据的极坐标图

关于这个图的代码如下:
#_*_coding:utf-8_*_
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
plt.style.use('ggplot') font=FontProperties(fname=r'c:\windows\fonts\simsun.ttc',size=12)
# 本行是为了有效显示中文的字体与大小 ability_size=6
ability_label=['进攻','防守','盘带','速度','体力','射术'] # 创建每个极坐标的位置
ax1=plt.subplot(221,projection='polar')
ax2=plt.subplot(222,projection='polar')
ax3=plt.subplot(223,projection='polar')
ax4=plt.subplot(224,projection='polar') player={
'M': np.random.randint(size=ability_size, low=60, high=99),
'H': np.random.randint(size=ability_size, low=60, high=99),
'P': np.random.randint(size=ability_size, low=60, high=99),
'Q': np.random.randint(size=ability_size, low=60, high=99),
} theta=np.linspace(0,2*np.pi,6,endpoint=False)
theta=np.append(theta,theta[0]) #下面分别画四个球员的能力极坐标图
player['M']=np.append(player['M'],player['M'][0])
ax1.plot(theta,player['M'],'r')
ax1.fill(theta,player['M'],'r',alpha=0.3)
ax1.set_xticks(theta)
ax1.set_xticklabels(ability_label,fontproperties=font)
ax1.set_title('梅西',fontproperties=font,color='r',size=20)
ax1.set_yticks([20,40,60,80,100]) player['H']=np.append(player['H'],player['H'][0])
ax2.plot(theta,player['H'],'g')
ax2.fill(theta,player['H'],'g',alpha=0.3)
ax2.set_xticks(theta)
ax2.set_xticklabels(ability_label,fontproperties=font)
ax2.set_title('哈维',fontproperties=font,color='g',size=20)
ax2.set_yticks([20,40,60,80,100]) player['P']=np.append(player['P'],player['P'][0])
ax3.plot(theta,player['P'],'b')
ax3.fill(theta,player['P'],'b',alpha=0.3)
ax3.set_xticks(theta)
ax3.set_xticklabels(ability_label,fontproperties=font)
ax3.set_title('皮克',fontproperties=font,color='b',size=20)
ax3.set_yticks([20,40,60,80,100]) player['Q']=np.append(player['Q'],player['Q'][0])
ax4.plot(theta,player['Q'],'y')
ax4.fill(theta,player['Q'],'y',alpha=0.3)
ax4.set_xticks(theta)
ax4.set_xticklabels(ability_label,fontproperties=font)
ax4.set_title('切赫',fontproperties=font,color='y',size=20)
ax4.set_yticks([20,40,60,80,100]) plt.show()
上述代码也可以利用for循环简化一下
#_*_coding:utf-8_*_
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
plt.style.use('ggplot') font=FontProperties(fname=r'c:\windows\fonts\simsun.ttc',size=12) ability_size=6
ability_label=['进攻','防守','盘带','速度','体力','射术'] ax1=plt.subplot(221,projection='polar')
ax2=plt.subplot(222,projection='polar')
ax3=plt.subplot(223,projection='polar')
ax4=plt.subplot(224,projection='polar') player={
'M': np.random.randint(size=ability_size, low=60, high=99),
'H': np.random.randint(size=ability_size, low=60, high=99),
'P': np.random.randint(size=ability_size, low=60, high=99),
'Q': np.random.randint(size=ability_size, low=60, high=99),
} theta=np.linspace(0,2*np.pi,6,endpoint=False)
theta=np.append(theta,theta[0]) color4=['r','b','g','y']
player4=['M','H','P','Q']
ax=[ax1,ax2,ax3,ax4]
name=['梅西','哈维','皮克','切赫']
for i in range(4):
player[player4[i]]=np.append(player[player4[i]],player[player4[i]][0])
ax[i].plot(theta,player[player4[i]],color4[i])
ax[i].fill(theta,player[player4[i]],color4[i],alpha=0.3)
ax[i].set_xticks(theta)
ax[i].set_xticklabels(ability_label,fontproperties=font)
ax[i].set_title(name[i],fontproperties=font,color=color4[i],size=20)
ax[i].set_yticks([20,40,60,80,100]) plt.show()
matplotlib实例笔记的更多相关文章
- SVN版本库(访问权限)配置实例笔记
http://blog.csdn.net/zjianbo/article/details/8578297 SVN版本库(访问权限)配置实例笔记 本系列文章由ex_net(张建波)编写,转载请注明出处. ...
- Matplotlib学习笔记(二)
原 Matplotlib学习笔记 参考:Python数据科学入门教程 Python3.6.1 jupyter notebook .caret, .dropup > .btn > .car ...
- Matplotlib学习笔记(一)
原 matplotlib学习笔记 参考:Python数据科学入门教程 Python3.6.1 jupyter notebook .caret, .dropup > .btn > .ca ...
- matplotlib学习笔记.CookBook
matplotlib 是Python下的一个高质量的画图库,可以简单的类似于MATLAB方法构建高质量的图表. 原始文章地址:http://zanyongli.i.sohu.com/blog/view ...
- Matplotlib 学习笔记
注:该文是上了开智学堂数据科学基础班的课后做的笔记,主讲人是肖凯老师. 数据绘图 数据可视化的原则 为什么要做数据可视化? 为什么要做数据可视化?因为可视化后获取信息的效率高.为什么可视化后获取信息的 ...
- matplotlib学习笔记
1.简介 matplotlib是python的一个2D绘图库,它可以在不同平台上地使用多种通用的绘图格式(hardcopy formats)和交互环境绘制出出版物质量级别的图片.matplotlib可 ...
- 科学计算和可视化(numpy及matplotlib学习笔记)
网上学习资料:https://2d.hep.com.cn/1865445/9 numpy库内容: 函数 描述 np.array([x,y,z],dtype=int) 从Python列表和元组创造数组 ...
- SQL经典实例笔记
目录 前言 第一章:检索记录 在Where字句中使用别名 前言 本文是根据我阅读的书籍SQL经典实例而写的笔记,只记载我觉得有价值的内容 第一章:检索记录 在Where字句中使用别名 --错误实例 s ...
- python画图matplotlib基础笔记
numpy~~基础计算库,多维数组处理 scipy~~基于numpy,用于数值计算等等,默认调用intel mkl(高度优化的数学库) pandas~~强大的数据框,基于numpy matplotli ...
随机推荐
- 在Ubuntu下安装VWMare tools
之前随便解压在一个目录下一直不能安装,后来把压缩包解压到home目录下就可以了. 详细步骤:https://jingyan.baidu.com/article/597a0643356fdc312b52 ...
- https://suchprogramming.com/epoll-in-3-easy-steps/
https://suchprogramming.com/epoll-in-3-easy-steps/ https://www.quora.com/What-are-the-key-difference ...
- bower 安装依赖提示 EINVRES Request to https://bower.herokuapp.com/packages/xxx failed with 502
出错提示EINVRES Request to https://bower.herokuapp.com/packages/chai failed with 502 访问 https://bower.he ...
- Tosca:设置执行结束时间
- linux服务之dns
安装dig工具 [root@cu-app-107 ~]# cat /etc/redhat-releaseCentOS Linux release 7.5.1804 (Core) [root@cu-ap ...
- Dart自定义库、系统库和第三方库
/* 前面介绍Dart基础知识的时候基本上都是在一个文件里面编写Dart代码的,但实际开发中不可能这么写,模块化很重要,所以这就需要使用到库的概念. 在Dart中,库的使用时通过import关键字引入 ...
- Ionic app IOS 在Xcode 模拟运行 真机调试
1. 创建项目: sudo ionic start myApp tabs 2 cd 到刚才创建的项目 3. sudo ionic cordova platform add ios 把 ios 环境添加 ...
- osg创建灯光
添加光照 osg::ref_ptr<osg::Node> MyOSGLoadEarth::CreateNode() { osg::ref_ptr<osg::Group> _ro ...
- ABAP DEMO33 选择周的搜索帮助
效果图 *&---------------------------------------------------------------------**& Report YCX_02 ...
- 【翻译】The Broadcast State Pattern(广播状态)
本文翻译自官网:The Broadcast State Pattern Provided APIs (提供的api) BroadcastProcessFunction and KeyedBroadca ...