python画图-python画图汇总(持续更新)
折线图
plt.figure(figsize=(40, 40)) # 确定图像画布的大小
plt.subplot(211) # 将画布分为两行一列
plt.xlabel('Number of sample', fontsize=40) # x轴的label
plt.ylabel('Characteristics of the amplitude', fontsize=40) # y轴的label 备注(plot所有的原件都可以加fontsize属性)
plt.title('{} characteristics (ml_id=2 waveType=2)'.format(c_type), fontsize=50) # 图的title
plt.plot(two_type_list[:two_negative_end_index], linestyle = "-", color = 'r', # 绘制折线图,其中若x参数省略,则横坐标以y列表的索引代替
label = 'Negative | average: {} variance: {} median: {}'.format(('%.2f' % np.mean(two_type_list[ : two_negative_end_index])), # label参数表示这条线的label,可以当作图例显示出来
('%.2f' % np.var(two_type_list[ : two_negative_end_index])),
('%.2f' % np.median(two_type_list[ : two_negative_end_index]))),
linewidth=3.0) # 线宽
plt.plot(two_type_list[two_negative_end_index+1:], linestyle = "-", color = 'g', # 备注(一张图可以累积加多个plot)
label = 'Positive | average: {} variance: {} median: {}'.format(('%.2f' % np.mean(two_type_list[two_negative_end_index+1 : ])),
('%.2f' % np.var(two_type_list[two_negative_end_index+1 : ])),
('%.2f' % np.median(two_type_list[two_negative_end_index+1 : ]))),
linewidth=3.0)
# plt.ylim(0, 5) # 设置y轴的取值范围,如设置(0,5)则y轴坐标为从0开始,到5结束
# 刻度值字体大小设置
plt.tick_params(labelsize=40) # 设置坐标轴上刻度的字体大小
plt.legend(loc=0, fontsize = 40) # 显示图例,loc=0表示图例会根据图片情况自动摆放
####################################################################################################################################
plt.subplot(212)
plt.xlabel('Number of sample', fontsize=40)
plt.ylabel('Characteristics of the amplitude', fontsize=40)
plt.title('{} characteristics (ml_id=6 waveType=2)'.format(c_type), fontsize=50)
plt.plot(six_type_list[:six_negative_end_index], linestyle = "-", color = 'r',
label = 'Negative | average: {} variance: {} median: {}'.format(('%.2f' % np.mean(six_type_list[ : six_negative_end_index])),
('%.2f' % np.var(six_type_list[ : six_negative_end_index])),
('%.2f' % np.median(six_type_list[ : six_negative_end_index]))),
linewidth=3.0)
plt.plot(six_type_list[six_negative_end_index+1:], linestyle = "-", color = 'g',
label = 'Positive | average: {} variance: {} median: {}'.format(('%.2f' % np.mean(six_type_list[six_negative_end_index+1 : ])),
('%.2f' % np.var(six_type_list[six_negative_end_index+1 : ])),
('%.2f' % np.median(six_type_list[six_negative_end_index+1 : ]))),
linewidth=3.0)
# 刻度值字体大小设置
plt.tick_params(labelsize=40)
plt.legend(loc=0, fontsize = 40)
plt.savefig('C:/Users/Mloong/Desktop/f_image/{} characteristics.png'.format(c_type), dpi=300)
plt.show()
2.散点图
_type = 'median'
plt.scatter(range(0, 3790), two_avgAbs_list[0:3790], c='r') # 散点图的x参数不可省略
plt.scatter(range(3791, 4939), two_avgAbs_list[3791:4939], c='g')
plt.title('{} ml_id=2 waveType=2'.format(_type))
plt.savefig('C:/Users/Mloong/Desktop/f_image/{} scatter ml_id=2 waveType=2.png'.format(_type), dpi=300)
plt.show()
3.概率分布图
# 概率分布图
type_list = two_median_list
_type = 'median'
num_bins = 100 # 条状图的个数
plt.hist(type_list[:3790], num_bins, normed=1, facecolor='blue', alpha=0.5)
plt.hist(type_list[3791:], num_bins, normed=1, facecolor='red', alpha=0.5)
plt.xlabel('Value')
plt.ylabel('Probability')
plt.title('{} probability distribution ml_id=2 waveType=2'.format(_type))
plt.subplots_adjust(left=0.15)
plt.savefig('C:/Users/Mloong/Desktop/f_image/{} probability distribution ml_id=2 waveType=2.png'.format(_type), dpi=300)
plt.show()
4.箱形图
_type = 'pca_value'
import seaborn as sns
plt.subplot(121)
plt.title('{} (ml_id=2 waveType=2)'.format(_type))
sns.set(style='whitegrid') # 设置背景
sns.boxplot(x='label', y='{}'.format(_type), data=two_data, hue='label') # data参数是一个dataframe对象,其中x和y分别时这个dataframe中的列名
#########################################################################################
plt.subplot(122)
plt.title('{} (ml_id=6 waveType=2)'.format(_type))
sns.set(style='whitegrid') # 设置背景
sns.boxplot(x='label', y='{}'.format(_type), data=six_data, hue='label') # 绘制箱形图
plt.savefig('C:/Users/Mloong/Desktop/f_image/{} box figure.png'.format(_type), dpi=300)
plt.show()
5.热图
# 2.相关矩阵
import seaborn as sns
corrmat = two_data[['avs', 'avgAbs', 'rms', 'rms2', 'wave', 'pulse', 'PeekFlag',
'Margin', 'Skewness', 'Kurtosis', 'median', 'pca_value', 'label']].corr() # .corr()求相关矩阵,此时返回的值corrmat为相关矩阵
f, ax = plt.subplots(figsize=(12, 9))
sns.heatmap(corrmat, vmax=.8, square=True) # 将这个相关矩阵以热图的形式画出来
plt.savefig('C:/Users/Mloong/Desktop/f_image/two correlation matrix.png', dpi=300)
plt.show()
python画图-python画图汇总(持续更新)相关推荐
- 【干货】Python:load_workbook用法(持续更新)
[干货]Python中load_workbook用法(持续更新) 功能 方法 示例文件 模块读取 导入excel表格 获取Sheet 查看行与列 查看单元格 批量访问数据 功能 读取excel文件,并 ...
- 【帆软报表】使用技巧及常见问题汇总-持续更新
[帆软报表]使用技巧及常见问题汇总-持续更新 1.重复与冻结设置,做用:冻结区域 模板-重复与冻结设置 2.单元格有效小数设置 选中单元格-格式-数字-#0.00 3.图表中有效小数设置 图表属性表- ...
- iOS精品资源汇总(持续更新)
文章目录 引言 I.iOS自定义视图相关热门资源 1.1 <用户协议及隐私政策>弹框 1.2 电子签名 1.3 商品详情页 1.4 上传图片视图的封装[支持删除和添加] 1.5 查看风险商 ...
- Telegram Android源码问题汇总 持续更新
libtgvoip目录为空 git clone下来的工程中带有submodule时,submodule的内容没有下载下来,执行如下命令 cd Telegram git submodule update ...
- 吉大计算机专硕报录比,22考研院校报录比汇总(持续更新)
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼 22考研院校报录比汇总(持续更新) 每个考研的小伙伴最关心的就是你所报考学校的报录比,因为这直接关系到你报考院校的难易程度,从中可以看出各高校的整体录取情 ...
- Unity学习知识和链接汇总-持续更新
Unity学习知识和链接汇总-持续更新 Unity Scripting Reference- https://docs.unity3d.com/Manual/index.html gitee http ...
- 【教程汇总+持续更新】Unity游戏开发从入门到入坟
新的一年,本该在年前整理的年终总结被拖到了年后开工.去年大量时间投入在Catlike教程的翻译上,截止目前位置,教程的进度已经完全追平原作者. 去年还有一部分是断断续续的更新SLG实战教程,但遗憾的是 ...
- Python常用命令总结【持续更新】
本来是草稿,趁着今天1024水一个勋章 目录 前言 文件读写 遍历文件夹/文件 生成随机颜色 numpy创建一个空白图像/数组,opencv画线 np创建一个指定颜色的图像/数组 生成随机数/随机矩阵 ...
- Python面试知识点(2020持续更新)
文章目录 一.Python宏观问题 ------1.Python自身------ 1.1.1. 到底什么是Python(Python语言特性)? 1.1.2. Python的优缺点? 1.1.3.说说 ...
- Android常用热门开源库汇总(持续更新)
原文转载:https://www.yundashi168.com/344.html 请及时关注原文网站,因为后续持续更新都在原网站更新.请多多点赞和关注. 前言 收集了一些比较常见的开源库,特此记录( ...
最新文章
- python在线课程-开始网上在线深度学习python课程
- 基础知识(9)- Swing用户界面组件
- wifi共享大师电脑版_Wifi分析助手PC版-Wifi分析助手电脑版下载 v7.2.2-
- (转) 淘淘商城系列——使用SolrJ查询索引库
- python加四位随机数_python生成四位随机数
- Android的setVisibility的三个参数
- JS阻止冒泡方法(转)
- top命令详解(转载)
- Python字符串逆序输出六种方法
- 详细的log4j配置使用流程
- 以《西游记》为例 详解游戏设计归纳演绎法
- LFM信号脉冲压缩原理和仿真
- Latex 中文使用方法和示例——分别基于MiKTeX(CTeX套装)、TeXLive 编译系统测试CJK、ctex 宏包,PDFLaTeX、XeLaTeX编译命令及GBK、UTF-8文件编码的使用
- php总结与展望_2020 年的 PHP 回顾与展望
- Android7.0(Android N)适配教程,心得
- 红米note9pro和华为Nova8哪个好 红米note9pro和华为Nova8哪个更加值得入手
- Windows上获取cpu info, cpuid, cpu id 方法整理
- 低空急流负风切变对风机的影响
- 第 5 章 ROS 常用组件 4 —— rosbag / rqt工具箱
- 大饼震荡不变,新平台搭建?
热门文章
- Tor真的匿名和安全吗?——如果是http数据,则在出口节点容易被嗅探明文流量,这就是根本问题...
- 使用CNN做电影评论的负面检测——本质上感觉和ngram或者LSTM同,因为CNN里图像检测卷积一般是3x3,而文本分类的话是直接是一维的3、4、5...
- JavaScript EventLoop
- NXT(未来币)(阿朵)节点钱包
- ActiveMQ消息队列的使用及应用
- 记一次CPU占用率和load高的排查
- [原][osg][gdal]两种方式修改tiff高程
- Spring配置多数据源错误总结
- hdu 携程全球数据中心建设 (球面距离 + 最小生成树)
- Spec Explorer 工具学习