日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python绘制剖面图_用python绘制剖面图

發布時間:2025/3/11 python 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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绘制剖面图的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。