Matlab plot not lining up correctly with x-axis

14 visualizzazioni (ultimi 30 giorni)
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);

Risposta accettata

Kevin Holly
Kevin Holly il 29 Nov 2021
Modificato: Kevin Holly il 29 Nov 2021
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)

Più risposte (0)

Categorie

Scopri di più su Visual Exploration in Help Center e File Exchange

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by