putting a text in a white space on a plot

17 ビュー (過去 30 日間)
Hassan
Hassan 2011 年 6 月 12 日
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');

採用された回答

Paulo Silva
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
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.
Hassan
Hassan 2011 年 6 月 12 日
Sorry Paulo for misspelling your name. Well, I just wondered someone may have it done it before since especially for me who is not good in programming it will take ages.

サインインしてコメントする。

その他の回答 (1 件)

Jan
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.
  1 件のコメント
Hassan
Hassan 2011 年 6 月 12 日
I will do and hope to find an answer there, thanks Jan for the help.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by