How to use text fuction in labeling

Hi guys I have a small issue. I'm doing a subplot where each plot symbolize a direction (North,East,West,South) so I have created a subplot with 3 rows and 3 columns, with the middle one empty. Now I want to label North, West, East and South in my subplot. I have tried TEXT function but it seem to be unstable. I have attached the figure so you can see what I'm dealing with. Hope you can help guys.
for j=1:length(SR) %Number of fields
figure
for i=[1:4 6:9] %Creating row x collums for subplot
for c=1:8 %Number of headings
subplot(3,3,i)
plot(omega,Sp_we(:,c,j))
xlabel('\omega [rad/s]')
ylabel('S(\omega)')
end
end
suptitle(['Wave spectrum for area ', num2str(SR(j))])
%text(2,20,'hello','FontSize',18)
%text(1.5,1,'hello','FontSize',18)
%text(1.5,1,'hello','FontSize',18)
%text(1.5,1,'hello','FontSize',18)
end

2 个评论

I don't see anything about N, S, E, W???
What's the specific problem? text coordinates are axes-based for each axes; you need to specify the current figure on which you wish to write and the the position within that axes.
annotation objects work in global figure space if that's what you're looking for.
Yeah I know ! thats the issue mann.. I want to write North at the second plot, and East at the plot nr. 5 in the left side an so on... If you know what I mean.. Like a compass

请先登录,再进行评论。

回答(1 个)

Adam
Adam 2014-5-27
编辑:Adam 2014-5-27
Hi Isa, do you mean something like this? (just copy this code to the Matlab command line and press ENTER)
test_signal_N = randn(1,100);
test_signal_S = randn(1,100);
test_signal_E = randn(1,100);
test_signal_W = randn(1,100);
test_signal_NE = randn(1,100);
test_signal_NW = randn(1,100);
test_signal_SE = randn(1,100);
test_signal_SW = randn(1,100);
figure;
subplot(3,3,1); plot(test_signal_NW); xlabel('\omega [rad/s]'); ylabel('S(\omega)'); title('North-West');
subplot(3,3,2); plot(test_signal_N); xlabel('\omega [rad/s]'); ylabel('S(\omega)'); title('North');
subplot(3,3,3); plot(test_signal_NE); xlabel('\omega [rad/s]'); ylabel('S(\omega)'); title('North-East');
subplot(3,3,4); plot(test_signal_W); xlabel('\omega [rad/s]'); ylabel('S(\omega)'); title('West');
subplot(3,3,6); plot(test_signal_E); xlabel('\omega [rad/s]'); ylabel('S(\omega)'); title('East');
subplot(3,3,7); plot(test_signal_SW); xlabel('\omega [rad/s]'); ylabel('S(\omega)'); title('South-West');
subplot(3,3,8); plot(test_signal_S); xlabel('\omega [rad/s]'); ylabel('S(\omega)'); title('South');
subplot(3,3,9); plot(test_signal_SE); xlabel('\omega [rad/s]'); ylabel('S(\omega)'); title('South-East');
Adam

4 个评论

Hi Adam... Actually that wasn't the idea. The idea was only to make North at the second plot, west at the 4. plot in the right side, east at the fifth plot at the left side and south at the 7. plot under the plot. But this seams to be perfect too :)) Do you know how I can move the label to the sides or under the plot? You know so it looks like a compass... But Thank you very much mann.. I Appreciate it very much...
regards
Ok, now I see your point. I guess there are some possibilities like commands text and annotation, however, these could be somehow hard to locate in the figure.
Another solution could be utilize title, y-label, x-label and opposite y-label for north, west, south and east, respectively. There is some way to split the text into two lines.
Or you can build a GUI, which is little bit more complicated, but quite a "clear" way...
Okay :) But the script you sent me is also useful.. Do you know how to use text function? If you want the title to be at the bottom and in the left and right side?
thanks
I have tried to figure out it... First solution is quite impractical, but it could work if you adjust it little bit -- mainly their absolut positions related to the size of figure. - see m-file attached
I´m sending you a second solution made by a GUI. Does it look like you imagine?
- see attached picture
Adam

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Labels and Annotations 的更多信息

提问:

2014-5-27

评论:

2014-5-28

Community Treasure Hunt

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

Start Hunting!

Translated by