MATLAB绘制泰勒图(Taylor diagram)

news2024/9/25 19:21:44

泰勒图(Taylor diagram)

泰勒图是Karl E. Taylor于2001年首先提出,主要用来比较几个气象模式模拟的能力,因此该表示方法在气象领域使用最多,但是在其他自然科学领域也有一定的应用。
泰勒图常用于评价模型的精度,常用的精度指标有相关系数(correlation coefficient)标准差(standard deviation)以及中心均方根误差(centered root-mean-square, RMSE)
一般而言,泰勒图中的散点代表模型,辐射线代表相关系数,横纵轴代表标准差,而虚线代表均方根误差。泰勒图一改以往用散点图这种只能呈现两个指标来表示模型精度的情况。
泰勒图分为标准化泰勒图未标准化泰勒图,用的比较多的是标准化泰勒图。标准化泰勒图即对参考值与变量值的标准差与均方根误差同除以参考值的标准差,令参考值=1,E=0,并消除其物理量单位。

泰勒图基本介绍

1 绘制包下载

安装网站:Taylor Diagram
在这里插入图片描述
Google Code Archive
此外,还需要"allstats"和"ptable"函数,下载链接分别如下:
Github-allstats.m函数

% STATM Compute statistics from 2 series
%
% STATM = allstats(Cr,Cf)
%
% Compute statistics from 2 series considering Cr as the reference.
% 
% Inputs:
%	Cr and Cf are of same length and uni-dimensional. They may contain NaNs.
%
% Outputs:
% 	STATM(1,:) => Mean
% 	STATM(2,:) => Standard Deviation (scaled by N)
% 	STATM(3,:) => Centered Root Mean Square Difference (scaled by N)
% 	STATM(4,:) => Correlation
%
% Notes:
%	- N is the number of points where BOTH Cr and Cf are defined
%
% 	- NaN are handled in the following way: because this function
% 		aims to compair 2 series, statistics are computed with indices
%		where both Cr and Cf are defined.
%
% 	- STATM(:,1) are from Cr (ie with C=Cr hereafter)
% 	  STATM(:,2) are from Cf versus Cr (ie with C=Cf hereafter)
%
%	- The MEAN is computed using the Matlab mean function.
%
%	- The STANDARD DEVIATION is computed as:
%			          /  sum[ {C-mean(C)} .^2]  \
%			STD = sqrt|  ---------------------  |
%			          \          N              /
%
%	- The CENTERED ROOT MEAN SQUARE DIFFERENCE is computed as:
%			           /  sum[  { [C-mean(C)] - [Cr-mean(Cr)] }.^2  ]  \
%			RMSD = sqrt|  -------------------------------------------  |
%			           \                      N                        /
%
%	- The CORRELATION is computed as:
%			      sum( [C-mean(C)].*[Cr-mean(Cr)] ) 
%			COR = --------------------------------- 
%			              N*STD(C)*STD(Cr)
%
%	- STATM(3,1) = 0 and STATM(4,1) = 1 by definition !
%
% Created by Guillaume Maze on 2008-10-28.
% Rev. by Guillaume Maze on 2010-02-10: Add NaN values handling, some checking
%				in the inputs and a more complete help
% Copyright (c) 2008 Guillaume Maze. 
% http://codes.guillaumemaze.org




%
% This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or any later version.
% This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
% You should have received a copy of the GNU General Public License along with this program.  If not, see <http://www.gnu.org/licenses/>.
%

function STATM = allstats(varargin)
	
Cr = varargin{1}; Cr = Cr(:);
Cf = varargin{2}; Cf = Cf(:);

%%% Check size:
if length(Cr) ~= length(Cf)
	error('Cr and Cf must be of same length');
end

%%% Check NaNs:
iok = find(isnan(Cr)==0 & isnan(Cf)==0);
if length(iok) ~= length(Cr)
	warning('Found NaNs in inputs, removed them to compute statistics');
end
Cr  = Cr(iok);
Cf  = Cf(iok);
N   = length(Cr);

%%% STD:
st(1) = sqrt(sum(  (Cr-mean(Cr) ).^2)  / N );
st(2) = sqrt(sum(  (Cf-mean(Cf) ).^2)  / N );
%st(1) = sqrt(sum(  (Cr-mean(Cr) ).^2)  / (N-1) );
%st(2) = sqrt(sum(  (Cf-mean(Cf) ).^2)  / (N-1) );

%%% MEAN:
me(1) = mean(Cr);
me(2) = mean(Cf);

%%% RMSD:
rms(1) = sqrt(sum(  ( ( Cr-mean(Cr) )-( Cr-mean(Cr) )).^2)  /N);
rms(2) = sqrt(sum(  ( ( Cf-mean(Cf) )-( Cr-mean(Cr) )).^2)  /N);

%%% CORRELATIONS:
co(1) = sum(  ( ( Cr-mean(Cr) ).*( Cr-mean(Cr) )))/N/st(1)/st(1);
co(2) = sum(  ( ( Cf-mean(Cf) ).*( Cr-mean(Cr) )))/N/st(2)/st(1);


%%% OUTPUT
STATM(1,:) = me;
STATM(2,:) = st;
STATM(3,:) = rms;
STATM(4,:) = co;
	
end %function	

Github-ptable.m函数
ptable.m函数如下:

% PTABLE Creates non uniform subplot handles
%
% SUBPLOT_HANDLE = ptable(TSIZE,PCOORD)
%
% This function creates subplot handles according to
% TSIZE and PCOORD.
% TSIZE(2) is the underlying TABLE of subplots: TSIZE(1)
%	is the number of lines, TSIZE(2) the number of rows
% PCOORD(:,2) indicates the coordinates of the subplots, ie
% 	for each PCOORD(i,2), the subplot i extends from
%	initial subplot PCOORD(i,1) to subplot PCOORD(i,2)
%
% Example: 
%	figure
% 	subp = ptable([3 4],[1 6 ; 3 4 ; 9 11; 8 8]);
%	x = 0:pi/180:2*pi;
%	axes(subp(1));plot(x,cos(x));
%	axes(subp(2));plot(x,sin(x));
%	axes(subp(3));plot(x,sin(x.^2));
%	axes(subp(4));plot(x,sin(x).*cos(x));
%
% Copyright (c) 2008 Guillaume Maze. 
% http://codes.guillaumemaze.org

%
% This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or any later version.
% This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
% You should have received a copy of the GNU General Public License along with this program.  If not, see <http://www.gnu.org/licenses/>.
%

% TO DO: 
%		- insert input check

function varargout = ptable(varargin)
	

tsize  = varargin{1}; % [iw jw] of the underlying table
pcoord = varargin{2};

%figure
iw  = tsize(1);
jw  = tsize(2);
tbl = reshape(1:iw*jw,[jw iw])';
for ip = 1 : iw*jw
	subp(ip) = subplot(iw,jw,ip);
end

% INITIAL POSITIONS:
for ip = 1 : iw*jw
	posi0(ip,:) = get(subp(ip),'position');	
end

% HIDE UNNCESSARY PLOTS:
for ip = 1 : iw*jw
	if isempty(find(pcoord(:,1)==ip))
		set(subp(ip),'visible','off');
%		set(subp(ip),'color','w');
	else
%		set(subp(ip),'color','r');
	end
end

% CHANGE SUBPLOT WIDTH:
for ip = 1 : size(pcoord,1)
	ip1 = pcoord(ip,1);
	ip2 = pcoord(ip,2);
	wi = posi0(ip2,1) + posi0(ip2,3) - posi0(ip1,1);
	set(subp(ip1),'position',[posi0(ip1,1:2) wi posi0(ip1,4)]);
end

% CHANGE SUBPLOT HEIGHT:
for ip = 1 : size(pcoord,1)
	ip1 = pcoord(ip,1);
	ip2 = pcoord(ip,2);
	
	% Find the lines we are in:
	[l1 c1] = find(tbl==ip1);
	[l2 c2] = find(tbl==ip2);
	% Eventually extent the plot:
	if l1 ~= l2
		wi = posi0(ip2,1) + posi0(ip2,3) - posi0(ip1,1);
		hg = posi0(ip1,2) + posi0(ip1,4) - posi0(ip2,2);
		bt = posi0(ip2,2);
		set(subp(ip1),'position',[posi0(ip1,1) bt wi hg]);
	end
end



if nargout >=1
	varargout(1) = {subp(pcoord(:,1))};
end

1.1 函数说明

markerLabel 图例的名称;markerLegend on为显示图例,off不显示;
styleSTD,sd的线型;colOBS,

名称Name说明
‘tickRMS’坐标刻度范围
‘tickSTD’坐标刻度范围
‘tickCOR’坐标刻度范围
markerLabel图例的名称
markerLegend图例的名称[‘on’/‘off’]
styleSTDsd的线型
colOBS参考点颜色‘r’

2 案例

2.1 案例1

结果如下:
在这里插入图片描述
MATLAB代码如下:

clear
%% 导入数据
pathFigure= '.\Figures\' ;
load taylordiag_egdata.mat

% Get statistics from time series:
for ii = 2:size(BUOY,1)
    C = allstats(BUOY(1,:),BUOY(ii,:));
    statm(ii,:) = C(:,2);
end
statm(1,:) = C(:,1);

% Plot:
figureUnits = 'centimeters';
figureWidth = 30; 
figureHeight = 12;

figure(1)
set(gcf, 'Units', figureUnits, 'Position', [0 0 figureWidth figureHeight]);
ax = ptable([2 3],[2 2;4 6]);
iw=1;
jw=2;
alphab = 'ABCDEFG';

subplot(iw,jw,1); 
plot(BUOY');
grid on;
xlabel('time (day)','FontSize',12,'FontName','Times New Roman');
ylabel('heat fluxes (W/m^2)','FontSize',12,'FontName','Times New Roman');
title(sprintf('%s: These are the different time series of daily heat fluxes (W/m^2)','A'),'fontweight','bold','FontSize',12,'FontName','Times New Roman');
set(gca,'FontSize',12,'Fontname', 'Times New Roman');
set(gca,'Layer','top');

subplot(iw,jw,2); 
hold on
[pp tt axl] = taylordiag(squeeze(statm(:,2)),squeeze(statm(:,3)),squeeze(statm(:,4)),...
            'tickRMS',[25:25:150],'titleRMS',0,'tickRMSangle',135,'showlabelsRMS',0,'widthRMS',1,...
            'tickSTD',[25:25:250],'limSTD',250,...
            'tickCOR',[.1:.1:.9 .95 .99],'showlabelsCOR',1,'titleCOR',1);

for ii = 1 : length(tt)
    set(tt(ii),'fontsize',9,'fontweight','bold')
    set(pp(ii),'markersize',12)
    if ii == 1
        set(tt(ii),'String','Buoy');
    else
        set(tt(ii),'String',alphab(ii-1));
    end
end
title(sprintf('%s: Taylor Diagram at CLIMODE Buoy','B'),'fontweight','bold','FontSize',12,'FontName','Times New Roman');

tt = axl(2).handle;
for ii = 1 : length(tt)
    set(tt(ii),'fontsize',10,'fontweight','normal','FontSize',12,'FontName','Times New Roman');
end
set(axl(1).handle,'fontweight','normal','FontSize',12,'FontName','Times New Roman');
set(gca,'FontSize',12,'Fontname', 'Times New Roman');
set(gca,'Layer','top');

str= strcat(pathFigure, "Fig.1", '.tiff');
print(gcf, '-dtiff', '-r600', str);

2.2 案例2

参考

1.CSDN博客-泰勒图(Taylor diagram)
2.CSDN博客-超干货 | 泰勒图(Taylor diagram)绘制方法大汇总
3.MATLAB绘制泰勒图(10个以上model)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/372067.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

使用命令别名一键启动arthas

1. 使用命令别名启动arthas 确保单板上有jdk和arthas jdk目录&#xff1a;/home/xinliushijian/arthas/jdk arthas目录&#xff1b;/home/xinliushijian/arthas su xinliushijian编写脚本messi.sh cd /home/xinliushijian/arthas vi messi.sh 内容如下&#xff1a; #!/bin/ba…

「兔了个兔」玉兔踏青,纯CSS实现瑞兔日历(附源码)

&#x1f482;作者简介&#xff1a; THUNDER王&#xff0c;一名热爱财税和SAP ABAP编程以及热爱分享的博主。目前于江西师范大学会计学专业大二本科在读&#xff0c;同时任汉硕云&#xff08;广东&#xff09;科技有限公司ABAP开发顾问。在学习工作中&#xff0c;我通常使用偏后…

Hive中数据库和表的操作(HSQL)

数仓管理工具Hive可以将HDFS文件中的结构化数据映射成表&#xff0c; 利用HSQL对表进行分析&#xff0c;HSQL的底层运行机制&#xff0c;默认是MapReduce计算&#xff0c;也可以替换成Spark、Tez、Flink 计算结果存储在HDFS&#xff0c;像Hive中的库、表、字段、表所属库、表的…

Zebec社区上线ZIP-2(地平线升级行动)提案

此前&#xff0c;Zebec社区在上线了投票治理系统Zebec Node后&#xff0c;曾上线了首个提案ZIP-1&#xff0c;对Nautilus Chain的推出进行了投票&#xff0c;作为Zebec Chain上线前的“先行链”&#xff0c;该链得到了社区用户的欢迎&#xff0c;投通过票的比例高达98.3%。而Na…

[Java代码审计]—命令执行失效问题

前言 关于Java的命令执行其实一直都没有单独学习过&#xff0c;正好昨天师傅问了一个问题&#xff1a;命令执行时字符串和字符串数组用哪个更好一些。当时被问得有点懵难道不都一样么&#xff1f;其实不然&#xff0c;借此重新了解下RCE以及失效问题。 单例模式 常规命令执行…

基于STM32 电机库(5.4.4)的单电阻采样调试总结

目录 硬件调整 软件调整 下载运行 参数优化 总结 硬件调整 实验用的开发板和电机如下&#xff0c;在调单一电阻之前已经在三电阻的环境下把启动运行的参数已经调好了&#xff0c;这里不多说。调好后需要把硬件改成单电阻采样。 如下原理图&#xff1a; 只需要把R75,76两…

每个人都应该知道的5个NLP代码库

在本文中&#xff0c;将详细介绍目前常用的Python NLP库。内容译自网络。这些软件包可处理多种NLP任务&#xff0c;例如词性&#xff08;POS&#xff09;标注&#xff0c;依存分析&#xff0c;文档分类&#xff0c;主题建模等等。NLP库的基本目标是简化文本预处理。目前有许多工…

【6】linux命令每日分享——rm删除目录和文件

大家好&#xff0c;这里是sdust-vrlab&#xff0c;Linux是一种免费使用和自由传播的类UNIX操作系统&#xff0c;Linux的基本思想有两点&#xff1a;一切都是文件&#xff1b;每个文件都有确定的用途&#xff1b;linux涉及到IT行业的方方面面&#xff0c;在我们日常的学习中&…

loki 日志管理的安装部署使用

loki介绍 Loki是 Grafana Labs 团队最新的开源项目&#xff0c;是一个水平可扩展&#xff0c;高可用性&#xff0c;多租户的日志聚合系统。它的设计非常经济高效且易于操作&#xff0c;因为它不会为日志内容编制索引&#xff0c;而是为每个日志流编制一组标签。 不对日志进行…

python学习之手把手教你将图片变成黑白或彩色字符画(骚操作)

文章目录前言一、字符画的实现原理二、黑白字符画实现代码三、彩色字符画生成代码实现&#xff1a;总结前言 字符画这个话题&#xff0c;似乎早在贴吧时代就已经被玩烂了。在百度图片随便一搜索&#xff0c;就能够看到非常多。然后在这个时代&#xff0c;会编程的人越来越多&a…

Transformer输出张量的值全部相同?!

【bug】Transformer输出张量的值全部相同&#xff1f;&#xff01;现象原因解决现象 输入经过TransformerEncoderLayer之后&#xff0c;基本所有输出都相同了。 核心代码如下&#xff0c; from torch.nn import TransformerEncoderLayer self.trans TransformerEncoderLayer…

日记本-课后程序(JAVA基础案例教程-黑马程序员编著-第七章-课后作业)

【实验7-3】 日记本 【任务介绍】 1.任务描述 编写一个日记本功能的程序&#xff0c;使用字节流经日记的具体信息记录在本地的txt文件中。当用户输入日记的特定内容后&#xff0c;会将输入的内容保存至本地的txt文件中。需要输入的内容包括“姓名”&#xff0c;“天气”、“…

OpenFeign详解

OpenFeign是什么&#xff1f; OpenFeign&#xff1a; OpenFeign是Spring Cloud 在Feign的基础上支持了SpringMVC的注解&#xff0c;如RequesMapping等等。OpenFeign的FeignClient可以解析SpringMVC的RequestMapping注解下的接口&#xff0c;并通过动态代理的方式产生实现类&am…

基于YOLOv5的细胞检测实战

数据及代码链接见文末 1.任务与数据集介绍 如下图所示,我们有一个医学细胞数据集,需要从数据集中检测出三种不同的细胞。标签中已经标注了细胞的类别和位置。 我们也可以看到,三种细胞有着不同的形态和颜色,同时数据集的标签也存在没有标注到的细胞 2.数据与标签配置方…

【打卡-Coggle竞赛学习2023年2月】图节点嵌入

文章目录## Part4 图节点嵌入### 背景介绍### 环境配置### 学习打卡- 任务1&#xff1a;图属性与图构造- 任务2&#xff1a;图查询与遍历- 任务3&#xff1a;节点中心性与应用- 任务4&#xff1a;图节点嵌入算法&#xff1a;- 任务5&#xff1a;图节点嵌入算法&#xff1a;- 任…

PowerAutomation获取邮件附件并删除这个邮件方法

这个文章是怎么来的呢&#xff1f;现在不是低代码开发平台启蒙阶段嘛&#xff1f;笔者也有幸在工作中进行了尝试&#xff0c;目前也已经在实际工作中结合Python进行了使用&#xff0c;当然&#xff0c;是可以提高IT的工作效率的。需求是这样的&#xff0c;想从公司的EBS平台报表…

3.5 实战:Spring Boot 实现系统多环境配置

第3章 Spring Boot 的系统配置 3.1 Spring Boot 系统配置文件 3.2 Spring Boot 自定义配置项 3.3 Spring Boot 其他配置 3.4 Spring Boot 日志配置 3.5 实战&#xff1a;Spring Boot 实现系统多环境配置 3.5 实战&#xff1a;Spring Boot 实现系统多环境配置 在实际项目开发的…

python的所有知识点(含讲解),不看就亏死了

目录 简介 特点 搭建开发环境 版本 hello world 注释 文件类型 变量 常量 数据类型 运算符和表达式 控制语句 数组相关 函数相关 字符串相关 文件处理 对象和类&#xff0c;注&#xff1a;不是那个对象&#xff01;&#xff01;&#xff01;&#xff01;&…

2023年安徽省职业院校技能大赛“网络空间安全” 比赛任务书

2023年安徽省职业院校技能大赛“网络空间安全” 比赛任务书 一、竞赛时间 总计:360分钟 二、竞赛阶段 竞赛阶段 任务阶段 竞赛任务 竞赛时间 分值 A模块 A-1 登录安全加固 180分钟 200分 A-2 Nginx安全策略 A-3 日志监控 A-4 中间件服务加固 A-5 本地安全策略 A-6 防火墙策…

基本程序设计技术

一.统计&#xff08;计数&#xff09;问题&#xff1a;方法&#xff1a;计数变量c的初值为0&#xff0c;每输入一个数据&#xff0c;进行必要判断后&#xff0c;若输入的数据满足统计条件&#xff0c;则计数变量c自加1&#xff0c;这样当对所有输入进行判断后&#xff0c;计数变…