Matlab plot not lining up correctly with x-axis
조회 수: 11 (최근 30일)
이전 댓글 표시
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);
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Visual Exploration에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!