Matlab plot not lining up correctly with x-axis
14 次查看(过去 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!