MATLAB: Add a scale bar to the plot

axis appereancescale bar

Hello, I was just wondering if there would be any way to replace the axis line for some sort of a scale bar. I am quite convinced there is no built command for this in matlab, so I was wondering how you guys would tweak the plot in order to get this. Just for the sake of illustration, this is what I have:
This is (sort of) what I wanted to obtain:
Thank you in advance for your collaboration!

Best Answer

This was an interesting project!
You will probably have to experiment to get exactly the effect you want, but this will get you going:
% Create Data —
t = linspace(10,34); % ‘t’ (ms)
y = [20+5*sin(2*pi*3*t/24)+2*randn(1,100); 60+5*cos(2*pi*3*t/24)+2*randn(1,100)];
figure(1)
plot(t, y)
hold on
plot([12; 12], [-40; -20], '-k', [12; 22], [-40; -40], '-k', 'LineWidth', 2)
hold off
axis([[10 34] -60 140])
text(11.8,-30, '10 mA', 'HorizontalAlignment','right')
text(17,-45, '10 ms', 'HorizontalAlignment','center')
% set(gca, 'XTick', [10:2:34], 'XTickLabel', {[] 12:2:32 []}) % Used temporarily to get the ‘text’ positions correct
set(gca, 'Visible', 'off')
Produces: