plot tools:add data color

조회 수: 287 (최근 30일)
Roger
Roger 2014년 1월 22일
댓글: Roger 2014년 1월 23일
the default color is blue,but i want to make the color of the data added black,so how to make it?

채택된 답변

AJ von Alt
AJ von Alt 2014년 1월 22일
If you want to make the line black at the time of plotting, add the argument 'k' to the plot command.
Example:
figure;
x = 0:0.1:10;
y = sin( x );
plot( x , y , 'k');
If you have a line that is blue and you want to make it black, you can use findobj to get the handle of the blue line and then set its color property value to black manually.
Example:
% plot something
figure;
x = 0:0.1:10;
y = sin( x );
plot( x , y , 'Blue' );
% the color values for blue and black
blue = [ 0 0 1 ];
black = [ 0 0 0 ];
% get the handle for the blue line
hline = findobj( gca , 'color' , blue );
% Set the line's color property value to black
set( hline(1) , 'color' , black )
  댓글 수: 3
AJ von Alt
AJ von Alt 2014년 1월 22일
The handle should ideally be the explicit handle of the axis containing the line that we wish to change (something like handles.axes1). This handle should be available as part of a gui function's arguments. If the entire figure is searched, handles for all blue lines in the entire figure will be returned.
Roger
Roger 2014년 1월 23일
yes,when i write set(findobj(gcf,'color','blue'),'color','black'); in mycommond window,all blue lines changed to black. there is a problem. the figure is maked by my gui , but after i wrote set(findobj(gcf,'color','blue'),'color','black'); in a pushbutton callback , it cannot work. what i want is to changed all blues lines to black once, then i need not to do it for every line by using plot tools,

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Amit
Amit 2014년 1월 22일

카테고리

Help CenterFile Exchange에서 Graphics Object Identification에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by