The last x-axis tick is missing/invisible in Fig.2 and 3
Greetings! I have plotted four figures. Figures 2 and 4 are right but Figures 2 and 3 don’t display the last tick at x-axis as shown in picture below.I have tried several other statements but the problem persist. The code is:
clear, clc, close all
a_ref = 0.05;
Reff_ref = 20;
z_bottom = 1000:1000:4000;
Height = linspace(0, 200, 1000); % Increased resolution for smoother lines
FOV = [0.2, 0.5, 1, 2, 5, 10];
cloud = ‘Homo’;
for h = 1:length(z_bottom)
main_fig = figure(‘NumberTitle’, ‘off’, ‘Name’, [‘Height ‘, num2str(z_bottom(h)), ‘m’]);
Area = []; % for sort
COLOR = {‘r’, ‘g’, ‘b’, [0.8500 0.3250 0.0980], [0.4660 0.6740 0.1880], [0 0.4470 0.7410]};
ylim_max = 0;
for a = 0.01:0.01:a_ref
for r = 4:Reff_ref
clf(main_fig); % Clear the current figure
subplot(1, 1, 1); % Create subplot for all FOVs
hold on;
for f = 1:length(FOV)
Height = genHeight(z_bottom(h))’;
load([‘MCdatabase_’, cloud, ‘/’, num2str(a), ‘-‘, num2str(r), ‘um/’, num2str(z_bottom(h)), ‘m-‘, num2str(FOV(f)), ‘mrad/I0.mat’]);
load([‘MCdatabase_’, cloud, ‘/’, num2str(a), ‘-‘, num2str(r), ‘um/’, num2str(z_bottom(h)), ‘m-‘, num2str(FOV(f)), ‘mrad/Q0.mat’]);
I_para = 1/2 * (I0 + Q0);
I_per = 1/2 * (I0 – Q0);
% Plotting all FOV plots on a single figure for each cloud height
plot(Height, sum(I_para, 2) .* Height.^2, ‘Color’, COLOR{f}, ‘LineWidth’, 1.5)
hold on
plot(Height, sum(I_per, 2) .* Height.^2, ‘Color’, COLOR{f}, ‘LineStyle’, ‘–‘, ‘LineWidth’, 1.5)
title([‘Height ‘, num2str(z_bottom(h)), ‘m’])
% Add annotation for polarized signals
if f == 1
annotation(‘textbox’, [0.15, 0.16, 0.1, 0.1], ‘String’, ‘P_{perp}’, ‘Color’, ‘k’, ‘EdgeColor’, ‘none’, ‘FontWeight’, ‘bold’, ‘FontSize’, 12);
annotation(‘textbox’, [0.22, 0.5, 0.1, 0.1], ‘String’, ‘P_{midmid}’, ‘Color’, ‘k’, ‘LineStyle’, ‘–‘, ‘EdgeColor’, ‘none’, ‘FontWeight’, ‘bold’, ‘FontSize’, 12);
end
Area = [Area, [z_bottom(h); FOV(f); pi * ((2.5 * cot(FOV(f) * 1e-3/2) + z_bottom(h)) * tan(FOV(f) * 1e-3/2))^2]];
% Calculate the maximum y-axis limit
ylim_max = max(ylim_max, max(sum(I_para, 2) .* Height.^2));
ylim_max = max(ylim_max, max(sum(I_per, 2) .* Height.^2));
end
hold off;
end
end
% Figure settings based on the data
zoom on
xlabel(‘Height of the cloud (m)’,’FontSize’,14,’FontWeight’,’normal’);
ylabel(‘Backscattering signal (Unit)’,’FontSize’,14,’FontWeight’,’normal’);
set(gca,’color’,’w’,’Fontsize’,12,’LineWidth’,1.5,’Fontweight’,’normal’);
set(gca,’box’,’off’,’Fontname’,’Arial’,’Fontsmoothing’,’on’);
% Set x-axis limits and ticks with a difference of 50 for all figures
xlim_min = z_bottom(h);
xlim_max = max(Height);
% Adjust xticks for last tick visibility
if h == 1
xticks = 1000:50:1150;
elseif h == 2
xticks = [2000 2050 2100 2150]; % Corrected x-ticks for Figure 2
elseif h == 3
xticks = [3000 3050 3100 3150]; % Corrected x-ticks for Figure 3
else
xticks = 4000:50:xlim_max;
end
set(gca,’xlim’,[xlim_min, xlim_max],’xtick’,xticks,’ylim’,[0 ylim_max],’ytick’,[0:0.1:ylim_max]);
set(gca,’xgrid’,’on’,’ygrid’,’on’,’gridcolor’,’k’);
% Create legend entries for each FOV value
legend_labels = cell(1, length(FOV) * 2); % Preallocate space for legend labels
for i = 1:length(FOV)
legend_labels{(i-1)*2+1} = [num2str(FOV(i)), ‘mrad’];
legend_labels{(i-1)*2+2} = [num2str(FOV(i)), ‘mrad’];
end
% Plot the legend entries in two rows
legend(legend_labels, ‘Location’, ‘NorthEast’, ‘NumColumns’, 3);
legend boxoff
end
I replaced the section but got the ticks with different values than desirable. The values should be 2150 and 3150 rather than mentionned.
% Adjust xticks for last tick visibility
if h == 1
xticks = 1000:50:1150;
elseif h == 2
xticks = [2000:50:2100, max(Height)]; % Corrected x-ticks for Figure 2
elseif h == 3
xticks = [3000:50:3100, max(Height)]; % Corrected x-ticks for Figure 3
else
xticks = 4000:50:xlim_max;
end
Please if anybody can solve it.Greetings! I have plotted four figures. Figures 2 and 4 are right but Figures 2 and 3 don’t display the last tick at x-axis as shown in picture below.I have tried several other statements but the problem persist. The code is:
clear, clc, close all
a_ref = 0.05;
Reff_ref = 20;
z_bottom = 1000:1000:4000;
Height = linspace(0, 200, 1000); % Increased resolution for smoother lines
FOV = [0.2, 0.5, 1, 2, 5, 10];
cloud = ‘Homo’;
for h = 1:length(z_bottom)
main_fig = figure(‘NumberTitle’, ‘off’, ‘Name’, [‘Height ‘, num2str(z_bottom(h)), ‘m’]);
Area = []; % for sort
COLOR = {‘r’, ‘g’, ‘b’, [0.8500 0.3250 0.0980], [0.4660 0.6740 0.1880], [0 0.4470 0.7410]};
ylim_max = 0;
for a = 0.01:0.01:a_ref
for r = 4:Reff_ref
clf(main_fig); % Clear the current figure
subplot(1, 1, 1); % Create subplot for all FOVs
hold on;
for f = 1:length(FOV)
Height = genHeight(z_bottom(h))’;
load([‘MCdatabase_’, cloud, ‘/’, num2str(a), ‘-‘, num2str(r), ‘um/’, num2str(z_bottom(h)), ‘m-‘, num2str(FOV(f)), ‘mrad/I0.mat’]);
load([‘MCdatabase_’, cloud, ‘/’, num2str(a), ‘-‘, num2str(r), ‘um/’, num2str(z_bottom(h)), ‘m-‘, num2str(FOV(f)), ‘mrad/Q0.mat’]);
I_para = 1/2 * (I0 + Q0);
I_per = 1/2 * (I0 – Q0);
% Plotting all FOV plots on a single figure for each cloud height
plot(Height, sum(I_para, 2) .* Height.^2, ‘Color’, COLOR{f}, ‘LineWidth’, 1.5)
hold on
plot(Height, sum(I_per, 2) .* Height.^2, ‘Color’, COLOR{f}, ‘LineStyle’, ‘–‘, ‘LineWidth’, 1.5)
title([‘Height ‘, num2str(z_bottom(h)), ‘m’])
% Add annotation for polarized signals
if f == 1
annotation(‘textbox’, [0.15, 0.16, 0.1, 0.1], ‘String’, ‘P_{perp}’, ‘Color’, ‘k’, ‘EdgeColor’, ‘none’, ‘FontWeight’, ‘bold’, ‘FontSize’, 12);
annotation(‘textbox’, [0.22, 0.5, 0.1, 0.1], ‘String’, ‘P_{midmid}’, ‘Color’, ‘k’, ‘LineStyle’, ‘–‘, ‘EdgeColor’, ‘none’, ‘FontWeight’, ‘bold’, ‘FontSize’, 12);
end
Area = [Area, [z_bottom(h); FOV(f); pi * ((2.5 * cot(FOV(f) * 1e-3/2) + z_bottom(h)) * tan(FOV(f) * 1e-3/2))^2]];
% Calculate the maximum y-axis limit
ylim_max = max(ylim_max, max(sum(I_para, 2) .* Height.^2));
ylim_max = max(ylim_max, max(sum(I_per, 2) .* Height.^2));
end
hold off;
end
end
% Figure settings based on the data
zoom on
xlabel(‘Height of the cloud (m)’,’FontSize’,14,’FontWeight’,’normal’);
ylabel(‘Backscattering signal (Unit)’,’FontSize’,14,’FontWeight’,’normal’);
set(gca,’color’,’w’,’Fontsize’,12,’LineWidth’,1.5,’Fontweight’,’normal’);
set(gca,’box’,’off’,’Fontname’,’Arial’,’Fontsmoothing’,’on’);
% Set x-axis limits and ticks with a difference of 50 for all figures
xlim_min = z_bottom(h);
xlim_max = max(Height);
% Adjust xticks for last tick visibility
if h == 1
xticks = 1000:50:1150;
elseif h == 2
xticks = [2000 2050 2100 2150]; % Corrected x-ticks for Figure 2
elseif h == 3
xticks = [3000 3050 3100 3150]; % Corrected x-ticks for Figure 3
else
xticks = 4000:50:xlim_max;
end
set(gca,’xlim’,[xlim_min, xlim_max],’xtick’,xticks,’ylim’,[0 ylim_max],’ytick’,[0:0.1:ylim_max]);
set(gca,’xgrid’,’on’,’ygrid’,’on’,’gridcolor’,’k’);
% Create legend entries for each FOV value
legend_labels = cell(1, length(FOV) * 2); % Preallocate space for legend labels
for i = 1:length(FOV)
legend_labels{(i-1)*2+1} = [num2str(FOV(i)), ‘mrad’];
legend_labels{(i-1)*2+2} = [num2str(FOV(i)), ‘mrad’];
end
% Plot the legend entries in two rows
legend(legend_labels, ‘Location’, ‘NorthEast’, ‘NumColumns’, 3);
legend boxoff
end
I replaced the section but got the ticks with different values than desirable. The values should be 2150 and 3150 rather than mentionned.
% Adjust xticks for last tick visibility
if h == 1
xticks = 1000:50:1150;
elseif h == 2
xticks = [2000:50:2100, max(Height)]; % Corrected x-ticks for Figure 2
elseif h == 3
xticks = [3000:50:3100, max(Height)]; % Corrected x-ticks for Figure 3
else
xticks = 4000:50:xlim_max;
end
Please if anybody can solve it. Greetings! I have plotted four figures. Figures 2 and 4 are right but Figures 2 and 3 don’t display the last tick at x-axis as shown in picture below.I have tried several other statements but the problem persist. The code is:
clear, clc, close all
a_ref = 0.05;
Reff_ref = 20;
z_bottom = 1000:1000:4000;
Height = linspace(0, 200, 1000); % Increased resolution for smoother lines
FOV = [0.2, 0.5, 1, 2, 5, 10];
cloud = ‘Homo’;
for h = 1:length(z_bottom)
main_fig = figure(‘NumberTitle’, ‘off’, ‘Name’, [‘Height ‘, num2str(z_bottom(h)), ‘m’]);
Area = []; % for sort
COLOR = {‘r’, ‘g’, ‘b’, [0.8500 0.3250 0.0980], [0.4660 0.6740 0.1880], [0 0.4470 0.7410]};
ylim_max = 0;
for a = 0.01:0.01:a_ref
for r = 4:Reff_ref
clf(main_fig); % Clear the current figure
subplot(1, 1, 1); % Create subplot for all FOVs
hold on;
for f = 1:length(FOV)
Height = genHeight(z_bottom(h))’;
load([‘MCdatabase_’, cloud, ‘/’, num2str(a), ‘-‘, num2str(r), ‘um/’, num2str(z_bottom(h)), ‘m-‘, num2str(FOV(f)), ‘mrad/I0.mat’]);
load([‘MCdatabase_’, cloud, ‘/’, num2str(a), ‘-‘, num2str(r), ‘um/’, num2str(z_bottom(h)), ‘m-‘, num2str(FOV(f)), ‘mrad/Q0.mat’]);
I_para = 1/2 * (I0 + Q0);
I_per = 1/2 * (I0 – Q0);
% Plotting all FOV plots on a single figure for each cloud height
plot(Height, sum(I_para, 2) .* Height.^2, ‘Color’, COLOR{f}, ‘LineWidth’, 1.5)
hold on
plot(Height, sum(I_per, 2) .* Height.^2, ‘Color’, COLOR{f}, ‘LineStyle’, ‘–‘, ‘LineWidth’, 1.5)
title([‘Height ‘, num2str(z_bottom(h)), ‘m’])
% Add annotation for polarized signals
if f == 1
annotation(‘textbox’, [0.15, 0.16, 0.1, 0.1], ‘String’, ‘P_{perp}’, ‘Color’, ‘k’, ‘EdgeColor’, ‘none’, ‘FontWeight’, ‘bold’, ‘FontSize’, 12);
annotation(‘textbox’, [0.22, 0.5, 0.1, 0.1], ‘String’, ‘P_{midmid}’, ‘Color’, ‘k’, ‘LineStyle’, ‘–‘, ‘EdgeColor’, ‘none’, ‘FontWeight’, ‘bold’, ‘FontSize’, 12);
end
Area = [Area, [z_bottom(h); FOV(f); pi * ((2.5 * cot(FOV(f) * 1e-3/2) + z_bottom(h)) * tan(FOV(f) * 1e-3/2))^2]];
% Calculate the maximum y-axis limit
ylim_max = max(ylim_max, max(sum(I_para, 2) .* Height.^2));
ylim_max = max(ylim_max, max(sum(I_per, 2) .* Height.^2));
end
hold off;
end
end
% Figure settings based on the data
zoom on
xlabel(‘Height of the cloud (m)’,’FontSize’,14,’FontWeight’,’normal’);
ylabel(‘Backscattering signal (Unit)’,’FontSize’,14,’FontWeight’,’normal’);
set(gca,’color’,’w’,’Fontsize’,12,’LineWidth’,1.5,’Fontweight’,’normal’);
set(gca,’box’,’off’,’Fontname’,’Arial’,’Fontsmoothing’,’on’);
% Set x-axis limits and ticks with a difference of 50 for all figures
xlim_min = z_bottom(h);
xlim_max = max(Height);
% Adjust xticks for last tick visibility
if h == 1
xticks = 1000:50:1150;
elseif h == 2
xticks = [2000 2050 2100 2150]; % Corrected x-ticks for Figure 2
elseif h == 3
xticks = [3000 3050 3100 3150]; % Corrected x-ticks for Figure 3
else
xticks = 4000:50:xlim_max;
end
set(gca,’xlim’,[xlim_min, xlim_max],’xtick’,xticks,’ylim’,[0 ylim_max],’ytick’,[0:0.1:ylim_max]);
set(gca,’xgrid’,’on’,’ygrid’,’on’,’gridcolor’,’k’);
% Create legend entries for each FOV value
legend_labels = cell(1, length(FOV) * 2); % Preallocate space for legend labels
for i = 1:length(FOV)
legend_labels{(i-1)*2+1} = [num2str(FOV(i)), ‘mrad’];
legend_labels{(i-1)*2+2} = [num2str(FOV(i)), ‘mrad’];
end
% Plot the legend entries in two rows
legend(legend_labels, ‘Location’, ‘NorthEast’, ‘NumColumns’, 3);
legend boxoff
end
I replaced the section but got the ticks with different values than desirable. The values should be 2150 and 3150 rather than mentionned.
% Adjust xticks for last tick visibility
if h == 1
xticks = 1000:50:1150;
elseif h == 2
xticks = [2000:50:2100, max(Height)]; % Corrected x-ticks for Figure 2
elseif h == 3
xticks = [3000:50:3100, max(Height)]; % Corrected x-ticks for Figure 3
else
xticks = 4000:50:xlim_max;
end
Please if anybody can solve it. missing_tick MATLAB Answers — New Questions