python绘制剖面图_用python绘制剖面图
我自己为这个功能做了一个模块。在import pandas as pd
from pandas import Series, DataFrame
import numpy as np
import matplotlib.pyplot as plt
def Profile(x,y,nbins,xmin,xmax,ax):
df = DataFrame({'x' : x , 'y' : y})
binedges = xmin + ((xmax-xmin)/nbins) * np.arange(nbins+1)
df['bin'] = np.digitize(df['x'],binedges)
bincenters = xmin + ((xmax-xmin)/nbins)*np.arange(nbins) + ((xmax-xmin)/(2*nbins))
ProfileFrame = DataFrame({'bincenters' : bincenters, 'N' : df['bin'].value_counts(sort=False)},index=range(1,nbins+1))
bins = ProfileFrame.index.values
for bin in bins:
ProfileFrame.ix[bin,'ymean'] = df.ix[df['bin']==bin,'y'].mean()
ProfileFrame.ix[bin,'yStandDev'] = df.ix[df['bin']==bin,'y'].std()
ProfileFrame.ix[bin,'yMeanError'] = ProfileFrame.ix[bin,'yStandDev'] / np.sqrt(ProfileFrame.ix[bin,'N'])
ax.errorbar(ProfileFrame['bincenters'], ProfileFrame['ymean'], yerr=ProfileFrame['yMeanError'], xerr=(xmax-xmin)/(2*nbins), fmt=None)
return ax
def Profile_Matrix(frame):
#Much of this is stolen from https://github.com/pydata/pandas/blob/master/pandas/tools/plotting.py
import pandas.core.common as com
import pandas.tools.plotting as plots
from pandas.compat import lrange
from matplotlib.artist import setp
range_padding=0.05
df = frame._get_numeric_data()
n = df.columns.size
fig, axes = plots._subplots(nrows=n, ncols=n, squeeze=False)
# no gaps between subplots
fig.subplots_adjust(wspace=0, hspace=0)
mask = com.notnull(df)
boundaries_list = []
for a in df.columns:
values = df[a].values[mask[a].values]
rmin_, rmax_ = np.min(values), np.max(values)
rdelta_ext = (rmax_ - rmin_) * range_padding / 2.
boundaries_list.append((rmin_ - rdelta_ext, rmax_+ rdelta_ext))
for i, a in zip(lrange(n), df.columns):
for j, b in zip(lrange(n), df.columns):
common = (mask[a] & mask[b]).values
nbins = 100
(xmin,xmax) = boundaries_list[i]
ax = axes[i, j]
Profile(df[a][common],df[b][common],nbins,xmin,xmax,ax)
ax.set_xlabel('')
ax.set_ylabel('')
plots._label_axis(ax, kind='x', label=b, position='bottom', rotate=True)
plots._label_axis(ax, kind='y', label=a, position='left')
if j!= 0:
ax.yaxis.set_visible(False)
if i != n-1:
ax.xaxis.set_visible(False)
for ax in axes.flat:
setp(ax.get_xticklabels(), fontsize=8)
setp(ax.get_yticklabels(), fontsize=8)
return axes
python绘制剖面图_用python绘制剖面图相关推荐
- python 时间序列预测_使用Python进行动手时间序列预测
python 时间序列预测 Time series analysis is the endeavor of extracting meaningful summary and statistical ...
- python 概率分布模型_使用python的概率模型进行公司估值
python 概率分布模型 Note from Towards Data Science's editors: While we allow independent authors to publis ...
- 用python实现点阵屏_用Python代码来绘制彭罗斯点阵的教程
这里是显示彭罗斯点阵的Python的脚本.是的,这是可以运行的有效Phython代码. 译注:彭罗斯点阵,物理学术语.上世纪70年代英国数学家彭罗斯第一次提出了这个概念,称为彭罗斯点阵(Pen-ros ...
- python 山脊图_纯Python绘制艺术感满满的山脊地图,创意满分
而今天的文章,我们就来一起基于 Python ,配合颜色与字体的选择搭配,使用简短的代码,就可以创作出艺术海报级别的 山脊地图 . 2 基于ridge_map的山脊地图绘制 我们主要使用 matplo ...
- python 山脊图_纯Python绘制满满艺术感的山脊地图
❝ 本文示例代码及附件已上传至我的Github仓库https://github.com/CNFeffery/DataScienceStudyNotes❞ 1 简介 下面的这幅图可能很多读者朋友们都看到 ...
- python绘制月亮_用 Python 画一个超级月亮
信息安全公益宣传,信息安全知识启蒙. 教程列表见微信公众号底部菜单 农历腊月十五 凌晨三点的街上 程序员给巡警解释 "同志,您误会了,我不是小偷,我是程序员." 于此同时 程序员错 ...
- python绘制月亮_用Python画一个超级月亮
信息安全公益宣传,信息安全知识启蒙. 教程列表见微信公众号底部菜单 农历腊月十五 凌晨三点的街上 程序员给巡警解释 "同志,您误会了,我不是小偷,我是程序员." 于此同时 程序员错 ...
- python主程序流程图_用Python编程绘制流程图,你用过吗?
您一定听说过 "Graphviz"绘图软件吧.Graphviz (Graph Visualization Software) 是一个由AT&T实验室启动的开源工具包,它采用 ...
- 用python绘制六角形_使用Python的turtle库实现六角形以及正方形螺旋线的绘制
1.六角形的绘制 思路:一个六角形可以看作是两个等边三角形具有共同的中心且垂线互成60°角.所以只需实现一个等边三角形的绘制以及第二个三角形绘制起点的移动即可. 代码如下: import turtle ...
- 使用python预测基金_使用python先知3 1创建预测
使用python预测基金 This tutorial was created to democratize data science for business users (i.e., minimiz ...
最新文章
- (转)在WCF服务的ServiceReferences.ClientConfig中使用相对路径
- ajax post传送数组以及java后台接收数组
- builtins自定义_ng-repeat里创建的自定义指令
- Emacs中的Color Theme以及字体设置
- GitLab五种权限
- OllyDbg笔记-暴力破解简单判断程序(TraceMe.exe与简单Qt程序)
- 共享内存进程线程混合通信
- 问题:gateway Invalid host lb://dabing_goods
- 微软再次“封杀” Flash Player!
- 公务员考试中公共基础知识计算机,2012山东省公务员考试公共基础知识最新考试试题库(完整版)...
- Java:JSON解析工具-org.json
- 干货 | 那些高产的学者都是怎样工作的?
- 女生真的不适合做程序么?。。我的成长之路。。
- 单片机c语言 课程设计报告,单片机课程设计心得体会精选
- matlab程序设计课件,《MATLAB程序设计》PPT课件.ppt
- SAP与ERP的区别联系
- window.open打开新标签页面
- VLOG的文字遮罩(利用文字显示内部)
- Evaluation of a 25-511keV List Mode Readout System for a Large Field-of-View Gamma Camera
- 10.pyecharts柱状图-----班级各地区男女所占人数
热门文章
- ci框架 乱码 mysql_mysql容器乱码问题
- oracle高水位线
- 使用Phpstorm实现远程开发
- Web框架之Django_01初识(三大主流web框架、Django安装、Django项目创建方式及其相关配置、Django基础三件套:HttpResponse、render、redirect)...
- 机器学习:样本集、验证集(开发集)、测试集
- 《Web安全之机器学习入门》一 第3章 机器学习概述
- 高晓松谈管理:自嘲总被员工管
- 在struts2中配置自定义拦截器放行多个方法
- 针对Parse error: syntax error, unexpected T_PUBLIC in D:报错提醒
- postfixadmin 导入数据库出错 ERROR 1062 (23000) at line 29