GithubHelp home page GithubHelp logo

wusir1122 / taylordiagram Goto Github PK

View Code? Open in Web Editor NEW

This project forked from muisedestiny/taylordiagram

0.0 0.0 0.0 36 KB

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

Python 100.00%

taylordiagram's Introduction

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再大也会显示,不会被裁剪

taylordiagram's People

Contributors

muisedestiny avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.