How can I change the color of a font with function text( ) in Matlab?

Go To StackoverFlow.com

1

marker={'r','b','g'};
for i=1:size(X,3)
    for r=1:size(X,1)
        for c=1:size(X,2)
            text(X(r,c,i),Y(r,c,i),Z(r,c,i),num2str(dof(c,r,i)))
        end
    end
end

For each value of i, I want to use a different color as given in marker to plot num2str(dof(c,r,i)). How can I do that? Thanks.

2012-04-05 19:52
by NoName


2

I'm on the wrong computer (no matlab for testing) right now, but

text(X(r,c,i),Y(r,c,i),Z(r,c,i),num2str(dof(c,r,i)), 'Color', marker{i})

should work. There will be problems if size(X,1)>3 this way however.

2012-04-05 20:01
by kaybe
Yeah, that works. Thanks kaybe - NoName 2012-04-05 20:10
Ads