Prevent last xlabel entry getting cut-off after adjusting xlim

조회 수: 1 (최근 30일)
JS
JS 2020년 5월 23일
댓글: JS 2020년 5월 24일
Hi,
So I'm trying to either:
  1. Prevent the last xlabel entry (12) from getting cut-off without increasing the range set using xlim as shown in the first image below.
  2. If were to adjust xlim in order to include the last xlabel entry, is there a way to either stretch out my plot to fill in the white space where my plot ends and still keep the last xlabel entry (12) as shown in the second image below.
This is my current script for generating the plots. The only thing I change to generate the plots shown in the images below is xlim:
%% Making Plot %%
clear
clc
close all
filename='fm.xlsx';
[A]=importdata(filename);
figure
hold on
for i = 1:5
plot(A(:,i),'LineWidth',1.5)
end
xlim([0 9000]) %the line I change either using xlim([0 9000]) or xlim([0 8640]), I have a total 8640 data points
ylim([0 1.0])
% axis([0 8640 0 1])
% axis tight
axis fill
box off;
xlims = get(gca,'XLim');
ylims = get(gca,'YLim');
line(xlims,[ylims(2) ylims(2)],'Color','black','LineWidth',1.5);
line([xlims(2) xlims(2)],ylims,'Color','black','LineWidth',1.5);
set(gca,'XMinorTick','on')
set(gca,'YMinorTick','on')
set(gca,'linewidth',1.5)
set(gca,'XTickLabel',{'';'4';'';'8';'';'9';'';'10';'';'12'})
size(get(gca,'XTick'))
Thanks!
  댓글 수: 6
Tommy
Tommy 2020년 5월 24일
Oh I see, I missed that the axis wasn't scaled linearly. You can still set the tick labels afterwards.
JS
JS 2020년 5월 24일
Thanks Tommy! Much appreciated. Got the end result I was looking for:

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by