Removing Text in MATLAB Graphics

  • MATLAB
  • Thread starter quantum13
  • Start date
  • Tags
    Matlab Text
In summary, there is a way to remove text from a plot on MATLAB by using the 'delete' method on the object handle for the text, which can be obtained by using the 'text' function. This allows for manipulation of the text's properties and can be used to delete it from the plot. More information can be found on the Mathworks website.
  • #1
quantum13
66
0
i'm using basic graphics on MATLAB where i use

text(x,y,'text as string')

to display text on a plot. is there a way to REMOVE this text? I tried overwriting it with ' ' and making the color white, font size 0, but none of these will remove the text.
 
Physics news on Phys.org
  • #2
If you use the following:
>> h1 = text(x,y,'text as string')

h1 will be an object handle to the text you just placed on your graph, allowing you to manipulate its properties, move it around, etc. You should also be able to delete it using the delete method:
>> delete(h1)

More documentation at the Mathworks website:
http://www.mathworks.com/help/techdoc/ref/delete.html
http://www.mathworks.com/help/techdoc/ref/text.html

I seem to recall that this should work, but don't have a copy of MATLAB at my work station.
 
  • #3
perfect solution, thanks
 

1. How do I remove text from a plot in MATLAB?

To remove text from a plot in MATLAB, you can use the delete function and specify the handle of the text object you want to remove. For example: delete(textHandle). This will delete the specific text object from your plot.

2. Can I remove all text from a plot at once in MATLAB?

Yes, you can remove all text from a plot at once by using the findobj function to find all text objects in the plot and then using the delete function to remove them. For example: delete(findobj(gca, 'Type', 'text')).

3. How can I remove the title or axis labels from a plot in MATLAB?

To remove the title or axis labels from a plot in MATLAB, you can use the title or xlabel/ylabel functions with an empty string as the input. For example: title('') or xlabel('').

4. Is it possible to hide text in a plot in MATLAB without removing it?

Yes, you can hide text in a plot in MATLAB without removing it by setting the Visible property of the text object to 'off'. For example: set(textHandle, 'Visible', 'off'). This will hide the text from the plot without deleting it.

5. How can I remove text from an image in MATLAB?

To remove text from an image in MATLAB, you can use the imtool function and click on the text to select it. Then, press the Delete key on your keyboard to remove the selected text from the image.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
328
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
782
  • Programming and Computer Science
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
801
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
23
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
Back
Top