Matlab plot not lining up correctly with x-axis

조회 수: 11 (최근 30일)
GG
GG 2021년 11월 29일
편집: Kevin Holly 2021년 11월 29일
I am trying to plot two different plots with the months as the x-axis and some data as y-axis. I have attached the plot that is drawn. I have tried using the xlim function but it still doesn't work. What is the problem with this code? I am using imported tables to calculate avg_T and avg_V. avg_T and avg_V both contain 12 values, same as the months but not all months are shown.
%Plotting%
Months_x={'Jan'; 'Feb'; 'Mar'; 'Apr'; 'May'; 'Jun'; 'Jul'; 'Aug'; 'Sep'; 'Okt'; 'Nov'; 'Dec';};
figure(1)
xlabel('Months');
ylabel('Average COP');
plot(avg_T)
xticklabels(Months_x);
figure(2)
xlabel('Months');
ylabel('Average Heat Leakage');
plot(avg_V)
xticklabels(Months_x);

채택된 답변

Kevin Holly
Kevin Holly 2021년 11월 29일
편집: Kevin Holly 2021년 11월 29일
You need to change the number of ticks along the x axis.
%Plotting%
Months_x={'Jan'; 'Feb'; 'Mar'; 'Apr'; 'May'; 'Jun'; 'Jul'; 'Aug'; 'Sep'; 'Okt'; 'Nov'; 'Dec';};
figure(1)
xlabel('Months');
ylabel('Average COP');
plot(avg_T)
xlim
xticklabels(Months_x);
xticks(1:12)
figure(2)
xlabel('Months');
ylabel('Average Heat Leakage');
plot(avg_V)
xticklabels(Months_x);
xticks(1:12)

추가 답변 (0개)

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by