Removing risidual ticks from second x axis
Mostrar comentarios más antiguos
Hi all, I am trying to create a plot with 2 x axis. I want there to be a single plot, but include a second x axis on the top, which contains the same data but for different units.
%x variable for bottom axis
xi=[0, 0.033 ,0.1];
%x variable for top axis
xi_b = [0.0197, 0.06, 0.123];
%variable for the y axis
k = [0.7,0,0];
figure(1)
t = tiledlayout(1,1);
ax1 = axes(t);
%plot 4 lines on first axis
plot(ax1,xi,k,'LineWidth',2)
hold on
%adjust stuff for this graph
set(gca,'FontSize',14)
xlabel('x1','FontSize',14)
ylabel('y1','FontSize',14)
ylim([0 1])
%add second axis at the top
ax2 = axes(t);
ax2.XAxisLocation = 'top';
ax2.YAxisLocation = 'right';
ax2.YAxis.Visible = 'off';
ax2.Color = 'none';
xlabel(ax2,'x2' )
set(ax2,'FontSize',14)
ax2.XLim = [xi_b(1),xi_b(end)];
It produces the following image. As you can see the top x axis has ticks from both the new x axis range, as well as ticks which align with the bottom x axis ticks. How do I remove the ticks at the topc which align the bottom x axis but keep the ones which correspond to the numbers on the top?
Respuesta aceptada
Más 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!

