- 'axis' function: https://www.mathworks.com/help/matlab/ref/axis.html
- 'colormap' function: https://www.mathworks.com/help/matlab/ref/colormap.html
- 'subplots': https://www.mathworks.com/help/matlab/ref/subplot.html
How to make an axis two different plots the same using the aspect ratio and how to set the contour colors the same.
5 次查看(过去 30 天)
显示 更早的评论
How to make an axis these two different plots the same using the aspect ratio and how to set the contour colors the same? Although my code is not here, an example will help.
0 个评论
回答(1 个)
Balavignesh
2024-2-11
Hi,
As per my understanding, you would like to ensure the different plots in MATLAB have the same aspect ratio and contour colors.
I would suggest you use the 'axis' function to set the aspect ration and 'colormap' function to synhronize the colors across plots. Below is an example code snippet that could help you understand this:
% Generate some sample data for the plots
[x, y] = meshgrid(linspace(-3, 3, 100), linspace(-3, 3, 100));
z1 = x.^2 + y.^2;
z2 = sin(x) + cos(y);
% Create the first plot
subplot(1, 2, 1);
contourf(x, y, z1, 20); % 20 contour levels
title('Plot 1');
xlabel('X-axis');
ylabel('Y-axis');
axis equal; % Set aspect ratio to be equal
colorbar;
% Create the second plot
subplot(1, 2, 2);
contourf(x, y, z2, 20); % 20 contour levels to match the first plot
title('Plot 2');
xlabel('X-axis');
ylabel('Y-axis');
axis equal; % Set aspect ratio to be equal
colorbar;
% Set the same colormap for both plots
colormap('jet'); % You can choose any colormap you prefer (e.g., 'jet', 'hsv', 'hot', etc.)
% If you want to synchronize the color limits (color scales) as well, you can do the following:
clims = [min([z1(:); z2(:)]), max([z1(:); z2(:)])]; % Find common color limits
subplot(1, 2, 1);
caxis(clims); % Set color limits for the first plot
subplot(1, 2, 2);
caxis(clims); % Set color limits for the second plot
Kindly have a look at the following documentation links to have more understanding on:
Hope that helps!
Balavignesh
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Orange 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!