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);

采纳的回答

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