xlim and ylim for contourf
38 次查看(过去 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!
0 个评论
采纳的回答
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 Center 和 File Exchange 中查找有关 Contour Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!