xlim and ylim for contourf

50 次查看(过去 30 天)
I need to add limits for the extent of where data was collected on a model. ie. the model goes from 0-900 but we only took measurements from 40-870 or something. I want the plot to show the full model dimensions.
I'm using contour plots. I have tried using xlim and ylim but it will only work for one or the other, depending where they appear in the code. I can't get it to use both.
subplot(1,4,1);
pressure_values = data_means(faces.front.tap_number);
faces.front.pressure = pressure_values;
x_size = length(unique(faces.front.x));
y_size = length(unique(faces.front.y));
z_size = length(unique(faces.front.z));
x_mesh = squeeze(reshape(faces.front.x,x_size,y_size,z_size));
y_mesh = squeeze(reshape(faces.front.y,x_size,y_size,z_size));
z_mesh = squeeze(reshape(faces.front.z,x_size,y_size,z_size));
pressure_mesh = squeeze(reshape(faces.front.pressure,x_size,y_size,z_size));
contourf(x_mesh, z_mesh, pressure_mesh,25,':');
colormap(gca,'jet')
hcb1 = colorbar;
title('FRONT');
ylim([0,900]);
xlim([-112.5,112.5]);
caxis(clims);
axis equal
Thanks!

采纳的回答

Raunak Gupta
Raunak Gupta 2020-10-2
Hi,
The axis equal command after xlim and ylim squeezes one of the axis limits to fit the figure box into minimum space. This happens due to PlotBoxAspectRatioMode being set to auto by default and it has stretch to fill inbuilt property. To get out of this expected behavior you can replace the order of axis and xlim/ylim commands. Last four lines of your code can be replaced as follows:
axis equal
ylim([0,900]);
xlim([-112.5,112.5]);
caxis(clims);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

产品


版本

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by