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 ...
随机推荐
- 解决url传递过程中加号变空格的问题<转>
url传递过程中加号变空格在接收url参数的过程中,会发现如果参数中存在‘+’号,接收后会变成空格. 如11+22接收后变成11 22.要解决这个问题,需要将加号替换为%2B进行传递. 如11%2B2 ...
- VS2017打包注册IE插件及修改IE安全选项设置【转】
前言 最近项目需要在浏览器环境下读取员工身份证信息,要实现网页与硬件设备通信,考虑了几种实现方式: 1.借助ActiveX插件,通过程序库直接与设备通信. 优点:厂家提供了IE插件,开发简单 缺点:只 ...
- js 对象 toJSON 方法
浅谈 js 对象 toJSON 方法 前些天在<浅谈 JSON.stringify 方法>说了他的正确使用姿势,今天来说下 toJSON 方法吧.其实我觉得这货跟 toString 一 ...
- PHP课程环境安装总结文档
phpStudy的安装 1.找一个硬盘根目录,比如这里我使用E盘,在E盘根目录创建一个php的文件夹,进入php文件夹,如下图所示 2.在步骤1的php文件夹下再建立一个文件夹php_dev,如下图所 ...
- Apollo源码打包及部署
1. 通过源码打包 到携程Apollo地址 https://github.com/ctripcorp/apollo 下载Apollo源码,可在源码中进行自定义配置日志路径及端口等,之后打包. 打包完成 ...
- Springboot配置文件获取系统环境变量的值
注意,这里说的是获取系统环境变量的值,譬如Windows里配置的JAVA_HOME之类的,可以直接在Springboot的配置文件中获取. 我们经常使用一些docker管理平台,如DaoCloud.r ...
- 泡泡一分钟:Project AutoVision - Localization and 3D Scene Perception for an Autonomous Vehicle with a Multi-Camera System
Project AutoVision - Localization and 3D Scene Perception for an Autonomous Vehicle with a Multi-Cam ...
- 浏览器显示 req Provisional headers are shown
现象: 原因: 请求被插件什么的拦截导致. 修复: 换浏览器也可以.
- Laya微信小游戏本地缓存
测试版本2.1.1.1 查看bin/libs/laya.wxmini.js. 发现只会缓存png,jpg. 声音和atlas,json不会缓存. 对比白鹭,白鹭是将png,jpg,atlas,json ...
- 报错:The specified datastore driver ("com.mysql.jdbc.Driver") was not found in the CLASSPATH. Please check your CLASSPATH specification, and the name of the driver.
报错背景: CDH中集成hive插件,启动报错. 报错现象: [main]: Metastore Thrift Server threw an exception... javax.jdo.JDOFa ...