Skip to content

绘制泰勒图,比其它库相比,可以指定绘制的ax,可调参数更灵活,需要手动添加legend,不裁剪参考点,多么的大都可以显示

Notifications You must be signed in to change notification settings

GreatMAN68/TaylorDiagram

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 

Repository files navigation

TaylorDiagram

绘制泰勒图,比其它库相比,可以指定绘制的ax,可调参数更灵活,需要手动添加legend 返回dia包含属性,他记录了所有绘制的点,可以直接调用dia.ax.legend()fig.legend(),然后调整位置即可

所需库

matplotlib

  1. matplotlib 3.4.2及以上
  2. pandas
  3. numpy

接受参数

ax, ref, samples, Normalize=False, markers=[], colors=[], scale=1.2, ms=10, mkwargs={}

ax为绘制的参考ax

ref参考值/真值的pandas.Series,即pandas.DataFrame的一列

samples为样本的pandas.DatsFrame,多列

markerscolors为绘制点的样式和颜色

scale乘积因子,获取最大的STD值Smax,然后将泰勒图限制在Smax*scale

ms即markersize,标记点大小

mkwargs标记点的其他参数,类型为字典

Normalize是否归一化

示例

import sys
sys.path.append("F:/python/NASA/matplotlib_advanced/")  # taylor_diagram.py所在目录
from taylor_diagram import TaylorDiagram
fig, axes = plt.subplots(1, 4, figsize=(24, 6), dpi=300)
fig.subplots_adjust(bottom=0.15, top=0.8)
for months, ax in zip([[12, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11]], axes):
    sub_df = df[df.month.isin(months)]
    dia = TaylorDiagram(ax, sub_df.iloc[:, 5], sub_df.iloc[:, 6:], ms=12, mkwargs=dict(markeredgecolor='none'))
    dia._ax.set_title('Month in ' + str(months))
fig.legend(dia.points, [p.get_label() for p in dia.points], loc='lower center', ncol=7, frameon=False, bbox_to_anchor=(0.1, 0, 0.8, 0.1))
dia.points

IPNF1t.png

fig, axes = plt.subplots(1, 4, figsize=(23, 6), dpi=300)
fig.subplots_adjust(bottom=0.15, top=0.8)
for months, ax in zip([[12, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11]], axes):
    sub_df = df[df.month.isin(months)]
    dia = TaylorDiagram(ax, sub_df.iloc[:, 5], sub_df.iloc[:, 6:], ms=12, mkwargs=dict(markeredgecolor='none'))
    dia._ax.set_title('Month in ' + str(months))
fig.legend(dia.points, [p.get_label() for p in dia.points], loc='lower center', ncol=7, frameon=False, bbox_to_anchor=(0.1, 0, 0.8, 0.1))
dia.points

IPStGE.png

特性

markersize再大也会显示,不会被裁剪

About

绘制泰勒图,比其它库相比,可以指定绘制的ax,可调参数更灵活,需要手动添加legend,不裁剪参考点,多么的大都可以显示

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%