title for plot segments

1 view (last 30 days)
Rotem Bachar
Rotem Bachar on 21 Mar 2021
Answered: Pavan Guntha on 25 Mar 2021
hi,
we plotted a graph og voltage as a function of time. The firing rate is different for each segment in the plot. We would like to add a title to each sagment stating the firing rate in it. We triend using a regular textbox with no luck. Thanks in advance!
plot(t, Si);
hold on
xlabel('t(sec)');
ylabel('V(mV)');
title('plot');
plot(LM,LM_Vol,'o','MarkerSize',3)
plot(L2H_Times, Si(L2H),'o','MarkerSize',3);
plot(H2L_Times, Si(H2L),'o','MarkerSize',3);
txt = 'Firing rate = 50';
dim =[0 1/18 0 0.2];
annotation('textbox', dim, 'string', txt);
hold off

Answers (1)

Pavan Guntha
Pavan Guntha on 25 Mar 2021
I understand that you would like to have multiple titles to a plot corresponding to the firing rate of various segments of that plot. You may try using the text and annotation commands to place text on the plot at appropriate position by providing the co-ordinates of the position at which the text is to be placed to those functions. Here's an example using text command:
figure(1)
plot(t, Si)
text(1, 8, '120 Hz') % Here (1,8) represents the co-ordinates at which '140 Hz' text would be placed.
text(3, 8, '140 Hz')
text(5, 8, '150 Hz')
text(7, 8, '100 Hz')
You can also implement this using the 'Edit plot' feature of Figure window ( Tools -> Edit Plot ) to move the postion of text boxes as per your convenience to make the textboxes look as titles for the respective segements. An illustration of this idea is shown in the figure below:

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!