x-axis values repeat themselves when I use tiledloyout for plots
Mostra commenti meno recenti
Hello,
I am using tiledlayout to combine my plots. However the values on the x axes are somehow repeating itself e.g. 0 1 2 3 4 0 1 2 3 4 when I used tiledlayout.
If you plot individually, the values are presented correctly:
%INDIVIDUAL PLOT
J19=plot(m19{1,:},-z19r1(1:end-1,1)',LineWidth=2);
hold on
J20=plot(m20{1,:},-z20_r1(1,1:end-1),LineWidth=2);
hold on
J22=plot(m22{1,:},-z22(1,1:end-1),LineWidth=2);
%hold off
%axes properties
ax = gca;
xtick_values = ax.XTick;
xtick_labels = compose('%.1e', xtick_values);
ax.XTickLabel = xtick_labels;
ax.XAxis.FontSize = 20;
ax.YAxis.FontSize = 20;

If you use tiledlayout, xaxes values are presented wrong:
%Tiledlayout
t = tiledlayout(1,2,'TileSpacing','Compact');
%first
nexttile
hAxes = gca;
J19=plot(hAxes,m19{1,:},-z19r1(1:end-1,1)',LineWidth=2);
hold on
J20=plot(hAxes,m20{1,:},-z20_r1(1,1:end-1),LineWidth=2);
hold on
J22=plot(hAxes,m22{1,:},-z22(1,1:end-1),LineWidth=2);
hold off
%axes properties
ax = gca;
xtick_values = ax.XTick;
xtick_labels = compose('%.1e', xtick_values);
ax.XTickLabel = xtick_labels;
ax.XAxis.FontSize = 20;
ax.YAxis.FontSize = 20;
%second
nexttile
hAxes = gca;
J19=plot(hAxes,m19{2,:},-z19r1(1:end-1,1)',LineWidth=2);
hold on
J20=plot(hAxes,m20{2,:},-z20_r1(1,1:end-1),LineWidth=2);
hold on
J22=plot(hAxes,m22{2,:},-z22(1,1:end-1),LineWidth=2);
hold off
%axes properties
ax = gca;
xtick_values = ax.XTick;
xtick_labels = compose('%.1e', xtick_values);
ax.XTickLabel = xtick_labels;
ax.XAxis.FontSize = 20;
ax.YAxis.FontSize = 20;

What might be the reason of the problem and how can I fix this issue?
Thank you in advance!
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Axes Appearance in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




