xlim and ylim for contourf

51 ビュー (過去 30 日間)
Alli Whalley
Alli Whalley 2020 年 9 月 28 日
コメント済み: Alli Whalley 2020 年 10 月 3 日
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);
  1 件のコメント
Alli Whalley
Alli Whalley 2020 年 10 月 3 日
That's great, thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-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