title for plot segments

조회 수: 2 (최근 30일)
Rotem Bachar
Rotem Bachar 2021년 3월 21일
답변: Pavan Guntha 2021년 3월 25일
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

답변 (1개)

Pavan Guntha
Pavan Guntha 2021년 3월 25일
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:

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by