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 ...
随机推荐
- 夺灵者哈卡(Hakkar, the Soulflayer)
Hakkar, the Soulflayer夺灵者哈卡Deathrattle: Shuffle a Corrupted Blood into each player's deck.亡语:将一张“堕落之 ...
- NPAPI插件开发详细记录:用VS2010开发NPAPI插件步骤<转>
原帖地址:https://blog.csdn.net/z6482/article/details/7660748 ------------------------------------------- ...
- Binder 原理剖析***
一. 前言 希望更加深入理解 Binder 实现机制的,可以阅读文末的参考资料以及相关源码. 二. Binder 概述 简单介绍下什么是 Binder.Binder 是一种进程间通信机制,基于开源的 ...
- JS Array.apply会有内存泄漏问题
报错内容: Maximum call stack size exceeded 参考:https://www.jianshu.com/p/b9ba0ddd3392 对象较多,前端JS内存溢出: 数组克隆 ...
- python 设计模式之工厂模式 Factory Pattern (简单工厂模式,工厂方法模式,抽象工厂模式)
十一回了趟老家,十一前工作一大堆忙成了狗,十一回来后又积累了一大堆又 忙成了狗,今天刚好抽了一点空开始写工厂方法模式 我看了<Head First 设计模式>P109--P133 这25页 ...
- ISO/IEC 9899:2011 条款6.6——常量表达式
6.6 常量表达式 语法 1.constant-expression conditional-expression 描述 2.一个常量表达式可以在翻译期间被计算,而不是在运行时,并且根据情况可以被用于 ...
- QCamera检测摄像头
The QCamera class provides interface for system camera devices. More... Header: #include <QCamera ...
- 泡泡一分钟:eRTIS - A Fully Embedded Real Time 3D Imaging Sonar Sensor for Robotic Applications
eRTIS - A Fully Embedded Real Time 3D Imaging Sonar Sensor for Robotic Applications eRTIS - 用于机器人应用 ...
- Django 引用{% url "name"%} 避免链接硬编码
前提条件:为每个url指定name且name值要唯一.比如: 项目中的url.py文件: urlpatterns = patterns('', url(r'^$',TemplateView.as_vi ...
- DELPHI XE MYSQL数据库操作类 MYSQLHELPER
注: 无需odbc配置 {* * MySQL Helper v1.0 * 2015.6.19 * 说明: * 这是一个操作MySQL的类,该类必须和libmysql.dll,dbxmys.dll两个文 ...