Different Xticks and labels in subplot
Mostrar comentarios más antiguos
How do I get the xticks, xlabels, yticks and ylabels for both subplots? I have tried the commented sections, but it didn't work. Here is my code:
syms x
Koppel = heaviside(x)-2*heaviside(x-6)+heaviside(x-10);
t = -2:0.005:12;
t1 = 0:0.005:10;
Koppel = double(subs(Koppel,x, 1.*t));
Poly5 = (3*t1)/16 - (5*(t1/5 - 1).^3)/8 + (3*(t1/5 - 1).^5)/16 - 7/16;
%% plot
setAcademicFigureSettings
figure
ax1 = subplot(2,1,1)
plot([-2 0], [0 0],t1,Poly5,[10 12], [1 1],'Color',1/255.*[0,46,101])
ylabel('Positie [rad]')
xlabel('Tijd [s]')
title('Bang-bang methode', 'FontSize',22)
% xticks([0 6 10]);
% xticklabels(ax1, {'t_{a}', 't_{switch}','t_{b}'}); % gewenste xtick labels
% yticks(ax1, [0 1]);
% yticklabels(ax1, {'\theta_{a}', '\theta_{b}'}); % gewenste xtick labels
ax2 = subplot(2,1,2)
plot(t,Koppel)
grid on
ylabel('Koppel [Nm]')
xlabel('Tijd [s]')
% xticks(ax1, [0 6 10]);
% xticklabels(ax1, {'t_{a}', 't_{switch}','t_{b}'}); % gewenste xtick labels
% yticks(ax1, [0 1]);
% yticklabels(ax1, {'\theta_{a}', '\theta_{b}'}); % gewenste xtick labels
% xticks(ax2,[0 6 10])
% xticklabels(ax2,{'t_{a}', 't_{switch}','t_{b}'})
% yticks(ax2,[-1 1])
% yticklabels(ax2,{'-T_{nom}', 'T_{nom}'})
% ylim(ax2,[-1.5 1.5])
% %set(ax2,'TickLabelInterpreter','tex')
3 comentarios
Walter Roberson
el 11 de Mayo de 2023
We do not have the function setAcademicFigureSettings to test with.
What difference is there between what you get and what you expect?
syms x
Koppel = heaviside(x)-2*heaviside(x-6)+heaviside(x-10);
t = -2:0.005:12;
t1 = 0:0.005:10;
Koppel = double(subs(Koppel,x, 1.*t));
Poly5 = (3*t1)/16 - (5*(t1/5 - 1).^3)/8 + (3*(t1/5 - 1).^5)/16 - 7/16;
%% plot
%setAcademicFigureSettings
figure
ax1 = subplot(2,1,1)
plot([-2 0], [0 0],t1,Poly5,[10 12], [1 1],'Color',1/255.*[0,46,101])
ylabel('Positie [rad]')
xlabel('Tijd [s]')
title('Bang-bang methode', 'FontSize',22)
% xticks([0 6 10]);
% xticklabels(ax1, {'t_{a}', 't_{switch}','t_{b}'}); % gewenste xtick labels
% yticks(ax1, [0 1]);
% yticklabels(ax1, {'\theta_{a}', '\theta_{b}'}); % gewenste xtick labels
ax2 = subplot(2,1,2)
plot(t,Koppel)
grid on
ylabel('Koppel [Nm]')
xlabel('Tijd [s]')
xticks(ax1, [0 6 10]);
xticklabels(ax1, {'t_{a}', 't_{switch}','t_{b}'}); % gewenste xtick labels
yticks(ax1, [0 1]);
yticklabels(ax1, {'\theta_{a}', '\theta_{b}'}); % gewenste xtick labels
xticks(ax2,[0 6 10])
xticklabels(ax2,{'t_{a}', 't_{switch}','t_{b}'})
yticks(ax2,[-1 1])
yticklabels(ax2,{'-T_{nom}', 'T_{nom}'})
ylim(ax2,[-1.5 1.5])
%set(ax2,'TickLabelInterpreter','tex')
Toon Van Dyck
el 12 de Mayo de 2023
Respuestas (0)
Categorías
Más información sobre Axes Appearance en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
