How To Create a Space Between Edge of a Plot and The Y-axis LineTick?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
vidyesh
am 10 Apr. 2024
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')
Antworten (0)
Siehe auch
Kategorien
Mehr zu Axis Labels finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!