필터 지우기
필터 지우기

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

조회 수: 6 (최근 30일)
Tunde Adubi
Tunde Adubi 2024년 4월 7일
댓글: vidyesh 2024년 4월 10일
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