我想制作一个 contour/surface 图,它显示单元格中的值,类似于 EFI 调整图
I want to make a contour/surface plot, which shows the values in the cells, similar to an EFI tuning map
我想在 MATLAB 中做这样的事情。这是一张地图,它有 x
和 y
轴以及 z
轴的值,z
值的大小用颜色表示。基本上是一个 countour 地图,它在屏幕上的矩阵中打印值
示例图:
修改 imagesc()
图
通过修改带有文本注释的 imagesc
图和创建网格的 line()
函数,这可能非常相似。需要完成一些轴属性(包括轴替换)才能正确配置绘图。不幸的是,这不是一种非常简洁的方法,但它可能会满足您的应用程序。
Engine_Load = [0.35 0.55 0.7 0.87 1 1.15 1.25 1.35 1.45 1.6 1.7 1.8 2 2.2 2.5];
Engine_Speed = (800:400:7600);
%Creating random test data%
[Engine_Load_Grid,Engine_Speed_Grid] = meshgrid(Engine_Load,Engine_Speed);
Estimated_Air_Fuel_Ratio = rand(length(Engine_Speed),length(Engine_Load));
%Creating the grid structure%
X_Axis = (1:length(Engine_Load));
Y_Axis = (1:length(Engine_Speed));
[X_Grid,Y_Grid] = meshgrid(X_Axis,Y_Axis);
clf;
imagesc('XData',X_Axis,'YData',Y_Axis,'CData',Estimated_Air_Fuel_Ratio);
xticks(1:1:length(X_Axis));
yticks(1:1:length(Y_Axis));
xlim([0.5 length(X_Axis)+0.5]);
ylim([0.5 length(Y_Axis)+0.5]);
Current_Axis = gca;
Current_Axis.XAxisLocation = 'Top';
grid on;
for Horizontal_Lines = 1: length(yticks)
line([0.5 length(X_Axis)+0.5],[Horizontal_Lines+0.5 Horizontal_Lines+0.5],'color','w','LineWidth',2);
end
for Vertical_Lines = 1: length(yticks)
line([Vertical_Lines+0.5 Vertical_Lines+0.5],[0.5 length(Y_Axis)+0.5],'color','w','LineWidth',2);
end
Estimated_Air_Fuel_Ratio = flip(Estimated_Air_Fuel_Ratio);
[Matrix_Height,Matrix_Width] = size(Estimated_Air_Fuel_Ratio);
for Row_Index = 1: Matrix_Height
for Column_Index = 1: Matrix_Width
text(Column_Index,Matrix_Height+1-Row_Index,num2str(Estimated_Air_Fuel_Ratio(Row_Index,Column_Index)));
end
end
Current_Figure = gcf;
set(findall(gcf,'type','text'),'HorizontalAlignment','center')
set(Current_Axis,'xtick',X_Axis,'xticklabel',Engine_Load);
set(Current_Axis,'ytick',Y_Axis,'yticklabel',Engine_Speed);
xlabel('Engine Load'); ylabel('Engine Speed');
colorbar
Current_Figure.Position = [0 0 1000 1000];
运行 使用 MATLAB R2019b
我想在 MATLAB 中做这样的事情。这是一张地图,它有 x
和 y
轴以及 z
轴的值,z
值的大小用颜色表示。基本上是一个 countour 地图,它在屏幕上的矩阵中打印值
示例图:
修改 imagesc()
图
通过修改带有文本注释的 imagesc
图和创建网格的 line()
函数,这可能非常相似。需要完成一些轴属性(包括轴替换)才能正确配置绘图。不幸的是,这不是一种非常简洁的方法,但它可能会满足您的应用程序。
Engine_Load = [0.35 0.55 0.7 0.87 1 1.15 1.25 1.35 1.45 1.6 1.7 1.8 2 2.2 2.5];
Engine_Speed = (800:400:7600);
%Creating random test data%
[Engine_Load_Grid,Engine_Speed_Grid] = meshgrid(Engine_Load,Engine_Speed);
Estimated_Air_Fuel_Ratio = rand(length(Engine_Speed),length(Engine_Load));
%Creating the grid structure%
X_Axis = (1:length(Engine_Load));
Y_Axis = (1:length(Engine_Speed));
[X_Grid,Y_Grid] = meshgrid(X_Axis,Y_Axis);
clf;
imagesc('XData',X_Axis,'YData',Y_Axis,'CData',Estimated_Air_Fuel_Ratio);
xticks(1:1:length(X_Axis));
yticks(1:1:length(Y_Axis));
xlim([0.5 length(X_Axis)+0.5]);
ylim([0.5 length(Y_Axis)+0.5]);
Current_Axis = gca;
Current_Axis.XAxisLocation = 'Top';
grid on;
for Horizontal_Lines = 1: length(yticks)
line([0.5 length(X_Axis)+0.5],[Horizontal_Lines+0.5 Horizontal_Lines+0.5],'color','w','LineWidth',2);
end
for Vertical_Lines = 1: length(yticks)
line([Vertical_Lines+0.5 Vertical_Lines+0.5],[0.5 length(Y_Axis)+0.5],'color','w','LineWidth',2);
end
Estimated_Air_Fuel_Ratio = flip(Estimated_Air_Fuel_Ratio);
[Matrix_Height,Matrix_Width] = size(Estimated_Air_Fuel_Ratio);
for Row_Index = 1: Matrix_Height
for Column_Index = 1: Matrix_Width
text(Column_Index,Matrix_Height+1-Row_Index,num2str(Estimated_Air_Fuel_Ratio(Row_Index,Column_Index)));
end
end
Current_Figure = gcf;
set(findall(gcf,'type','text'),'HorizontalAlignment','center')
set(Current_Axis,'xtick',X_Axis,'xticklabel',Engine_Load);
set(Current_Axis,'ytick',Y_Axis,'yticklabel',Engine_Speed);
xlabel('Engine Load'); ylabel('Engine Speed');
colorbar
Current_Figure.Position = [0 0 1000 1000];
运行 使用 MATLAB R2019b