How to make contour to have the same axes
6 次查看(过去 30 天)
显示 更早的评论
I have a two different plots with 2 different axes. The second plot (fig2) is extracted from the first plot (fig1).
Please how can I make the extract plot to have the same axis as the first one. I tried aspect ratio function but couldn't work.
openfig('fig1.fig');
openfig('fig2.fig');
11 个评论
Cris LaPierre
2024-2-9
Please share the code you used to create both plots.
Are you saying fig2 should keep the axes as labeled, with the plot filling the figure window, or should the figure essentially be zoomed to the exact borders of the contour plot so that it fills the figure window?
University
2024-2-9
Thank you Cris. Not really zooming it. I think I was able to zoom it with your assitance last week but that wasn't what I wanted. I want the fig2 to plot fill the figure window.
University
2024-2-9
See code:
fig2 = figure(2);
[C,h] = contourf(L, xi, intul, [min(min(intul)):0.05e-11:max(max(intul))],'ShowText','off','edgecolor','none');
c = colorbar;
c.TickLabelInterpreter='latex';
c.Label.String = '$\int u_L \mathrm{dz} $';
c.Label.Interpreter = 'latex';
colormap jet
clabel(C,h)
hold on
for i=1:length(L)
for j=1:length(xi)
plot(L(i), xi(j), 'w.', 'LineWidth', 2, 'MarkerSize', 5)
end
end
set(gca,'clim',[min(min(intul)) max(max(intul))]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fig2 = figure(2);
[C,h] = contourf(L, xi, intul, [min(min(intul)):0.05e-11:max(max(intul))],'ShowText','off','edgecolor','none');
c = colorbar;
c.TickLabelInterpreter='latex';
c.Label.String = '$\int u_L \mathrm{dz} $';
c.Label.Interpreter = 'latex';
colormap jet
clabel(C,h)
hold on
for i=1:length(L)
for j=1:length(xi)
plot(L(i), xi(j), 'w.', 'LineWidth', 2, 'MarkerSize', 5)
end
end
set(gca,'clim',[min(min(intul)) max(max(intul))]);
% axis label
xlabel('HAN region length, $l$ [m]','Interpreter','latex');
ylabel('activity, $\xi$','Interpreter','latex');
xlim([pars.W/1000, pars.W/3])
ylim([0, 125])
I set the limit of fig2 using the axix of fig1.
Cris LaPierre
2024-2-9
编辑:Cris LaPierre
2024-2-9
The reason it is not filling the axes is because you have set the limits of fig2 to be the same as fig1. If fig2 is indeed a subset of fig1, then you need to use the limits of the data in fig2 to set the axes limits. Otherwise, you are plotting it the same size it was in the original figure. Where there is no data remains white.
University
2024-2-9
编辑:Torsten
2024-2-9
Yeah I understand what you mean. This is the actual figure without setting the limit.
openfig('fig2_actual.fig');
Cris LaPierre
2024-2-9
Also, I think you copied the same code twice rather than code that creates the 2 figures you attached.
University
2024-2-9
The figures are coded differently. I added more points around the isolated maxumum to extract more information.
University
2024-2-9
% axis for first figure
xivals = linspace(0, 125, 20);
Lvals = linspace(2e-8, 6.6667e-6, 20);
% axis for second figure
xivals = linspace(47.8947, 123.158, 20);
Lvals = linspace(7.19649e-07, 3.51825e-06, 20);
I have attached data for each of the figures
Cris LaPierre
2024-2-9
编辑:Cris LaPierre
2024-2-9
Can you update your post to use the tools in the ribbon to create formatted code, and then run that code so that it creates each figure here? Smiilar to what I did here.
University
2024-2-9
编辑:Torsten
2024-2-9
load data_0_125.mat
figure;
xi = linspace(0, 125,20);
L=linspace(2e-08, 6.66666666666667e-06, 20);
[C,h] = contourf(L, xi, intul, [min(min(intul)):0.05e-11:max(max(intul))],'ShowText','off','edgecolor','none');
c = colorbar;
c.TickLabelInterpreter='latex';
c.Label.String = '$\int u_L \mathrm{dz} $';
c.Label.Interpreter = 'latex';
colormap jet
clabel(C,h)
hold on
for i=1:length(L)
for j=1:length(xi)
plot(L(i), xi(j), 'w.', 'LineWidth', 2, 'MarkerSize', 5)
end
end
set(gca,'clim',[min(min(intul)) max(max(intul))]);
Warning: Error updating Text.
String scalar or character vector must have valid interpreter syntax:
$\int u_L \mathrm{dz} $
String scalar or character vector must have valid interpreter syntax:
$\int u_L \mathrm{dz} $
%%%%%
load data_xi_48_123.mat
figure;
xivals = linspace(47.8947, 123.158, 20);
Lvals = linspace(7.19649e-07, 3.51825e-06, 20);
[C,h] = contourf(L, xi, intul, [min(min(intul)):0.05e-11:max(max(intul))],'ShowText','off','edgecolor','none');
c = colorbar;
c.TickLabelInterpreter='latex';
c.Label.String = '$\int u_L \mathrm{dz} $';
c.Label.Interpreter = 'latex';
colormap jet
clabel(C,h)
set(gca,'clim',[min(min(intul)) max(max(intul))]);
Warning: Error updating Text.
String scalar or character vector must have valid interpreter syntax:
$\int u_L \mathrm{dz} $
String scalar or character vector must have valid interpreter syntax:
$\int u_L \mathrm{dz} $
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)