Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
512 views
in Technique[技术] by (71.8m points)

matlab - I want to make a contour/surface plot, which shows the values in the cells, similar to an EFI tuning map

I want to make something like this in MATLAB. This is a map which has x and y axis and a value for the z axis with a color for the magnitude of the z value. Basically a countour map which prints values in the matrix on the screen

Sample graph: enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Modifying an imagesc() Plot

Here is something that might be similar enough by modifying an imagesc plot with text annotations and the line() function to create the grid. Some axis attributes including axis replacement needed to be done to configure the plot correctly. Unfortunately, it's not a very concise way of doing it but it might satisfy your application.

Imagesc Plot

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];

Ran using MATLAB R2019b


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...