putting a text in a white space on a plot
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuesta aceptada
Paulo Silva
el 12 de Jun. de 2011
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 comentarios
Paulo Silva
el 12 de Jun. de 2011
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.
Más respuestas (1)
Jan
el 12 de Jun. de 2011
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.
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!