0
votes

I have a gray-scale grid and used command below to print text on it which prints text in black.

text (cPixel+25, rPixel+25, 'X', 'HorizontalAlignment', 'center', 'VerticalAlignment', 'middle', 'FontSize', 38);

now, I want to remove this text, i am trying to do so by changing the text color to white using 'Color' property shown below but it prints in black.

text (cPixel+25, rPixel+25, 'X', 'HorizontalAlignment', 'center', 'VerticalAlignment', 'middle', 'FontSize', 38, 'Color', [1 1 1]);

If you please tell me that which property to use to make gray-scale color white. i used 'color' property with RGB value [1 1 1] it also prints text in black, and also tried with 'color' property with 1 as a gray-scale value, but, it gives me error that you should use [R G B] color value.

My Question is how to set gray-scale text color on a gray-scale grid using text() function in matlab. What i tried is briefed above. Thanks for your patience!

1

1 Answers

0
votes

Your code works for me. But maybe your problem is, that you are not really changing the color of the existing text object but instead create a new object on top of the old one.

To actually delete the old object, you need to keep the handle and then delete it:

textHandle = text(cPixel+25, rPixel+25, 'X', 'HorizontalAlignment', 'center', 'VerticalAlignment', 'middle', 'FontSize', 38);
delete(textHandle)

and if you actually want to change the color, you can also use the handle to do that:

set(textHandle,'Color',[0 0.5 1])