python - 如何绘制 3 个变量(深度、时间、参数)的热图
解决方案
在 MATLAB 中
下面是一种方法,它使用该meshgrid()
函数创建一个域,以便在Temperature
其上绘制/反对。要绘制 2D 热图,我们可以使用该函数surf()
将高度设置为顶视图(90 度) 。view()
根据您是否希望进行插值,shading interp
可以包含或删除使用。要获取时间标签,我们可以将 转换Time_Vector
为字符串数组并使用arrayfunc()
(数组函数).
用冒号替换点:
。最后,我们可以使用set()
当前轴上的函数,gca
在绘图上显示新格式化的时间标签。colormap()
可以设置为各种选项,例如、'hot'
、'winter'
等'spring'
。
Time_Vector = (10.00: 0.01: 10.09);
Depth_Vector = (1:3);
Temperature = [15 16 17 18 19 20 20 20 20 20;
25 30 35 40 45 50 50 50 50 50;
30 35 40 45 50 55 60 65 70 75];
[Time_Grid,Depth_Grid] = meshgrid(Time_Vector,Depth_Vector);
surf(Time_Grid,Depth_Grid,Temperature);
title("Heatmap");
xlabel("Time"); ylabel("Depth");
colormap(hot);
shading interp
Angle = 0; Elevation = 90;
view(Angle,Elevation);
colorbar;
%Time label adjustments%
Time_Labels = string(Time_Vector);
Time_Labels = arrayfun(@(x) replace(x,".",":"),Time_Labels);
set(gca,'xtick',Time_Vector,'xticklabel',Time_Labels);
使用 MATLAB R2019b 运行
推荐阅读
- git - git 存档名称中带有空格的文件
- php - Symfony 2.8 - ChoiceType 需要字符串,但登录需要角色是数组
- python - 手动引发异常的代码中的 Nosetests 错误
- python - 在 Python 中使用 Selenium 从某个 div 获取链接
- json - 在 Jmeter 中使用 JSON POST 数据中的参数时,会更改另一个 json 实体
- javascript - 拆分 Reducer 时出错
- mysql - 如何在 Select Query 中写入 OR 条件
- recursion - 如何找到变量,是否在恒定时间内完成
- xml - 使用 sed 或 awk 从包含方括号的 xml 替换 IP
- r - 使用“ppc_stat()”时直方图值失真