change color when i plot more surface fit

조회 수: 20 (최근 30일)
Giovanni Massaria
Giovanni Massaria 2022년 10월 18일
편집: Kevin Holly 2022년 10월 18일
Hi everyone, i need to change the color of the different surfaces that i found whit fit, adding a simple color command don't work, so how can i have different colors in the two surfaces? the first blue and the second red for example
fig10=figure(10);
[xData, yData, zData] = prepareSurfaceData( comfortval, cval, dval );
ft = fittype( 'poly44' );
opts = fitoptions( 'Method', 'LinearLeastSquares' );
opts.Robust = 'Bisquare';
fitresult = fit( [xData, yData], zData, ft, opts );
h1 = plot( fitresult, [xData, yData], zData );
hold on
[xData, yData, zData] = prepareSurfaceData( comfortvalBL, cvalBL, dvalBL );
ft = fittype( 'poly44' );
opts = fitoptions( 'Method', 'LinearLeastSquares' );
opts.Robust = 'Bisquare';
[fitresult, gof] = fit( [xData, yData], zData, ft, opts );
h2 = plot( fitresult, [xData, yData], zData); % if i add ,'r' at the end the programm don't work
hold on

답변 (1개)

Kevin Holly
Kevin Holly 2022년 10월 18일
편집: Kevin Holly 2022년 10월 18일
fig10=figure(10);
xData = rand(30,1);
yData = rand(30,1);
zData = rand(30,1);
ft = fittype( 'poly44' );
opts = fitoptions( 'Method', 'LinearLeastSquares' );
opts.Robust = 'Bisquare';
fitresult = fit( [xData, yData], zData, ft, opts );
h1 = plot( fitresult, [xData, yData], zData );
h1(1).FaceColor = 'b';
hold on
xData = rand(30,1);
yData = rand(30,1);
zData = rand(30,1);
ft = fittype( 'poly44' );
opts = fitoptions( 'Method', 'LinearLeastSquares' );
opts.Robust = 'Bisquare';
[fitresult, gof] = fit( [xData, yData], zData, ft, opts );
h2 = plot( fitresult, [xData, yData], zData);
h2(1).FaceColor = 'r';

카테고리

Help CenterFile Exchange에서 Fit Postprocessing에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by