Matlab画海洋与大气变量的时间序列并带标记面的三维折线图--来源粉丝

Matlab画带标记面的三维折线图--来源粉丝

图片

目标图:

图片

复现:

图片

细节可在代码中更改:

复制代码
数据构造
clear;clc;close all;
% 数据构造
X1= 1:8;Y1=ones(length(X1),1);
X2 = X1;Y2=2*ones(length(X1),1);
X3 = X1;Y3=3*ones(length(X1),1);
Z = fix(10*rand(8,3));
颜色表:
% 颜色表
color3 = [139 0 139]./255;
color2 =[60 179 113]./255;
color1 =[255 185 15]./255;
三维折线画图:
% 画图
close all
figure
set(gcf,'position',[50 50 800 550],'color','w')
h1=plot3(Y1,X1,Z(:,1),'linestyle','-','Marker',"hexagram",'color',color1,'LineWidth',2,'MarkerEdgeColor',color1,...
    'MarkerFaceColor',color1);
hold on
h2=plot3(Y2,X2,Z(:,2),'linestyle','-','Marker',"diamond",'color',color2,'LineWidth',2,'MarkerEdgeColor',color2,...
    'MarkerFaceColor',color2);
hold on
h3=plot3(Y3,X3,Z(:,3),'linestyle','-','Marker',">",'color',color3,'LineWidth',2,'MarkerEdgeColor',color3,...
    'MarkerFaceColor',color3);
hold on
添加平面并调整透明度:
% add plane
hold on
yy1 = [X1(1) X1(end) X1(end) X1(1)];
xx1 = [Y1(1) Y1(end) Y1(end) Y1(1)];
% zz1 = [min(Z(:,1)) min(Z(:,1)) max(Z(:,1)) max(Z(:,1)) ];
zz1 = [0 0 10 10];
fh1 = fill3(xx1,yy1,zz1,color1);
set(fh1,'FaceAlpha',0.1,'FaceColor',color1,'EdgeColor',color1);
yy2 = [X2(1) X2(end) X2(end) X2(1)];
xx2 = [Y2(1) Y2(end) Y2(end) Y2(1)];
zz2 = [0 0 10 10];
fh2 = fill3(xx2,yy2,zz2,color2);
set(fh2,'FaceAlpha',0.1,'FaceColor',color2,'EdgeColor',color2);
yy3 = [X3(1) X3(end) X3(end) X3(1)];
xx3 = [Y3(1) Y3(end) Y3(end) Y3(1)];
zz3 = [0 0 10 10];
fh3 = fill3(xx3,yy3,zz3,color3);
set(fh3,'FaceAlpha',0.1,'FaceColor',color3,'EdgeColor',color3);
更改视角刻度等细节:
% 改变视角
view([20 25 70])
% 设置xlabel 等刻度
xlim([0.9 3.2])
ylim([1 9])
zlabel([0 10])
xlabel('variables','fontsize',15,'fontweight','bold')
ylabel('year','fontsize',15,'fontweight','bold')
zlabel('number','fontsize',15,'fontweight','bold')
title('plot 3Dimension with plane','fontsize',15,'fontweight','bold')
set(gca,'xtick',[1:3],'xticklabel',{'sst','wind','flux'},'fontsize',12,'FontWeight','bold','ytick',0:9,'YTickLabel',[2020:-1:2010],'ztick',[0:2:10])
% grid on
grid on
box on

添加legend 并输出:
% add legend
le_h =legend([h1,h2,h3],'sst','wind','flux');
set(le_h,'position',[0.1 0.8 0.2 0.1],'box','off','fontsize',12,'FontWeight','bold')
export_fig('带标记面的三维折线图1.jpg','-r600')
全部代码 :
.rtcContent { padding: 30px; } .lineNode {font-size: 12pt; font-family: "Times New Roman", Menlo, Monaco, Consolas, "Courier New", monospace; font-style: normal; font-weight: normal; }
clear;clc;close all;
% 数据构造
X1= 1:8;Y1=ones(length(X1),1);
X2 = X1;Y2=2*ones(length(X1),1);
X3 = X1;Y3=3*ones(length(X1),1);
Z = fix(10*rand(8,3));
% 颜色表
color3 = [139 0 139]./255;
color2 =[60 179 113]./255;
color1 =[255 185 15]./255;
% 画图
close all
figure
set(gcf,'position',[50 50 800 550],'color','w')
h1=plot3(Y1,X1,Z(:,1),'linestyle','-','Marker',"hexagram",'color',color1,'LineWidth',2,'MarkerEdgeColor',color1,...
    'MarkerFaceColor',color1);
hold on
h2=plot3(Y2,X2,Z(:,2),'linestyle','-','Marker',"diamond",'color',color2,'LineWidth',2,'MarkerEdgeColor',color2,...
    'MarkerFaceColor',color2);
hold on
h3=plot3(Y3,X3,Z(:,3),'linestyle','-','Marker',">",'color',color3,'LineWidth',2,'MarkerEdgeColor',color3,...
    'MarkerFaceColor',color3);
hold on
% 改变视角
view([20 25 70])
% 设置xlabel 等刻度
xlim([0.9 3.2])
ylim([1 9])
zlabel([0 10])
xlabel('variables','fontsize',15,'fontweight','bold')
ylabel('year','fontsize',15,'fontweight','bold')
zlabel('number','fontsize',15,'fontweight','bold')
title('plot 3Dimension with plane','fontsize',15,'fontweight','bold')
set(gca,'xtick',[1:3],'xticklabel',{'sst','wind','flux'},'fontsize',12,'FontWeight','bold','ytick',0:9,'YTickLabel',[2020:-1:2010],'ztick',[0:2:10])
% grid on
grid on
box on
% add plane
hold on
yy1 = [X1(1) X1(end) X1(end) X1(1)];
xx1 = [Y1(1) Y1(end) Y1(end) Y1(1)];
% zz1 = [min(Z(:,1)) min(Z(:,1)) max(Z(:,1)) max(Z(:,1)) ];
zz1 = [0 0 10 10];
fh1 = fill3(xx1,yy1,zz1,color1);
set(fh1,'FaceAlpha',0.1,'FaceColor',color1,'EdgeColor',color1);
yy2 = [X2(1) X2(end) X2(end) X2(1)];
xx2 = [Y2(1) Y2(end) Y2(end) Y2(1)];
zz2 = [0 0 10 10];
fh2 = fill3(xx2,yy2,zz2,color2);
set(fh2,'FaceAlpha',0.1,'FaceColor',color2,'EdgeColor',color2);
yy3 = [X3(1) X3(end) X3(end) X3(1)];
xx3 = [Y3(1) Y3(end) Y3(end) Y3(1)];
zz3 = [0 0 10 10];
fh3 = fill3(xx3,yy3,zz3,color3);
set(fh3,'FaceAlpha',0.1,'FaceColor',color3,'EdgeColor',color3);
% add legend
le_h =legend([h1,h2,h3],'sst','wind','flux');
set(le_h,'position',[0.1 0.8 0.2 0.1],'box','off','fontsize',12,'FontWeight','bold')
export_fig('带标记面的三维折线图1.jpg','-r600')
相关推荐
q***92516 分钟前
sql实战解析-sum()over(partition by xx order by xx)
数据库·sql
gladiator+8 分钟前
Redis之BigKey的常见问题以及大厂相关面试题
java·数据库·redis
合方圆~小文12 分钟前
AI摄像头精准识别技术依赖于深度算法
数据结构·数据库·数码相机·模块测试
tanxiaomi23 分钟前
Redis相关面试题
数据库·redis·缓存
Controller-Inversion38 分钟前
岛屿问题(dfs典型问题求解)
java·算法·深度优先
钮钴禄·爱因斯晨1 小时前
【探索实战】KuratorGitOps 多环境配置管理与合规审计
数据库
okseekw1 小时前
Java 字符串三巨头:String、StringBuilder、StringJoiner —— 初学者避坑指南 🤯
java
Z***G4791 小时前
【零基础学Mysql】常用函数讲解,提升数据操作效率的利器
数据库·mysql
q***06471 小时前
Spring Boot 从 2.7.x 升级到 3.3注意事项
数据库·hive·spring boot
毕设源码余学姐1 小时前
计算机毕设 java 中医药药材分类采购网站 SSM 框架药材交易平台 Java 开发的分类采购与订单管理系统
java·开发语言·课程设计