putting a text in a white space on a plot
11 次查看(过去 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!