putting a text in a white space on a plot
조회 수: 7 (최근 30일)
이전 댓글 표시
I have some plots that I want to write a text on them but I want to place the text in a white space inside plot. I wonder how I can do that?
x=rand(10,10);
y=rand(10,10);
plot(x,y,'o'); % I want to show the following text in a white space inside the plot window
text('L=C0*D+C1');
댓글 수: 0
채택된 답변
Paulo Silva
2011년 6월 12일
What you are asking for isn't easy to implement but can be done, what the code has to do is the search for one empty space big enough for that text, there's also a chance that there's no such space available and the code will fail.
There are alternatives like using the legend, xlabel, ylabel and title. Also title can have many lines
title({'Main Title text'; 'Subtitle text'});
or this solution:
title(['\fontsize{14} Main Title ', ...
'\newline \fontsize{10} \color{red} \it My Subtitle']);
There is also the gtext function that allows the user to select where to put the text.
댓글 수: 3
Paulo Silva
2011년 6월 12일
My name is Paulo not Paula, what you want to do is waste time and add more code to your program just to do that simple thing, ok buy you already know the basic idea "what I meant was finding a space with less density of data (or maximum white space) and putting the text in center of it" so start coding that and see if it's really needed.
추가 답변 (1개)
Jan
2011년 6월 12일
Look in the code of LEGEND, subfunction lscan. This function has 92 lines, because the task is not trivial. But when the found location is nice for a legend, a text may be matching also.
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!