How To Create a Space Between Edge of a Plot and The Y-axis LineTick?

6 次查看(过去 30 天)
How Can I create a space between the edge of the right hand plot and the y-axis lineTick from the code below? That is, to seperate the plot edge from the right y-axis Tickline.
This code generates the figure in plot1. But the figure in plot2 is desired.
desired_azimuth = 272;
figure('position',[100 100 900 550])
hold on
yyaxis left
plot(range, pia_cumulative12191, 'LineWidth', 2.0, 'Color', 'k') % Set plot color to black
set(gca, 'FontName', 'Arial', 'FontWeight', 'bold', 'xlim', [30 60], 'ylim', [0 25], 'FontSize', 14, 'YColor', 'k', 'YMinorTick', 'on') % Set axis properties
xlabel('Range (km)', 'FontSize', 15)
ylabel('Cumulative PIA (dB/km)', 'FontSize', 15, 'Color', 'k') % Set label color to black
yyaxis right
plot(range, pia_ref_12191, 'LineWidth', 2.0, 'Color', 'b') % Set plot color to blue
set(gca, 'ylim', [-10 70], 'FontSize', 14, 'YColor', 'b', 'YMinorTick', 'on') % Set axis properties including minor ticks
ylabel('Reflectivity (dBZ)', 'FontSize', 15, 'Color', 'b') % Set label color to blue
line = xline([39.2 45.3], '--k', 'LineWidth', 2.0);
str = {'Region of', 'Melting Ice'};
text(40.5, 2.0, str, 'Color', 'black', 'FontSize', 15)
label1 = 'PIA';
label2 = 'Z_{Measured}';
legend(label1, label2, 'Interpreter', 'tex', 'Location', 'northwest', 'FontSize', 15, 'EdgeColor', 'k', 'FontWeight', 'bold'); % Set legend properties
title(['PIA and Reflectivity', ' | ', 'Azimuth: ', num2str(desired_azimuth), '^o', ' | ', 'Elevation: 0.7', '^o', ' | ', '12:19 UTC'], ...
'FontSize', 15, 'FontWeight', 'bold', 'color', 'k');
grid on
set(gca, 'LineWidth', 2, 'Box', 'on') % Set edge box of the entire plot to bold
hold off
  1 个评论
vidyesh
vidyesh 2024-4-10
Adding the below line of code will not add a gap between the figure and ticks but it may help in addressing the issue:
set(gca,"TickDir",'out')

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Axis Labels 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by