MATLAB: I would like to draw a plot like below just exact like image below, How to do that

MATLABplot drawing with special level

Best Answer

x=[1:6];
y=[0.19 0.525 1.175 2.795 7.008 20.210];
ax_invisible=axes('color','none','Ytick',[]);
ax2=axes;
plot(x, y, 'r-')
box off
set(gca, 'xgrid', 'off', 'ygrid', 'on')
title('start/stop time (in seconds)', 'FontWeight', 'bold');
legend('Time')
set(gca,'XTick',1:6,'tickdir','out', 'XtickLabel',[])
xt = arrayfun(@(x) {sprintf('%d', 2.^(x+1) - 1)}, x);
set(ax_invisible,'Xlim',get(ax2,'Xlim'),'XTick',x+0.5,'Xticklabel',xt);
Note that the legend is inside the plot. Positing the legend outside messes things up.