Changing the color of a 3D plot

25 views (last 30 days)
EM
EM on 4 Aug 2020
Commented: KSSV on 4 Aug 2020
Hi everyone,
I'm plotting two 3D ssurface plots that are generated from the cure fitting toolbox. In the following you can see how I call the plots. The problem is that, both plots have the same color. I want to change the color of at least one of the plots to be recognizable from the other. I appreciate you help.
figure(1)
U = LF_fit(Nc_1, Eo_L1, s_1);
hold on
V = HF_fit(Nc_2, Eo_2, s_2);
hold on
  2 Comments
KSSV
KSSV on 4 Aug 2020
LF_fit, HF_fit are not inbuilt functions.....those are user defined functions. You need to post the functions here to see how the plotting is done.
EM
EM on 4 Aug 2020
Edited: Rik on 4 Aug 2020
Here is one of the functions: (the otherone is similat)
function [fitresult, gof] = HF_fit(Nc_HF, Eo_HF, s_d_or_HF)
%CREATEFIT(NC_HF,EO_HF,S_D_OR_HF)
% Create a fit.
% Data for 'untitled fit 1' fit:
% X Input : Nc_HF
% Y Input : Eo_HF
% Z Output: s_d_or_HF
% Output:
% fitresult : a fit object representing the fit.
% gof : structure with goodness-of fit info.
% See also FIT, CFIT, SFIT.
% Auto-generated by MATLAB on 08-Jul-2020 20:13:56
%% Fit: 'untitled fit 1'.
[xData, yData, zData] = prepareSurfaceData( Nc_HF, Eo_HF, s_d_or_HF );
% Set up fittype and options.
ft = fittype( 'poly13' );
% Fit model to data.
[fitresult, gof] = fit( [xData, yData], zData, ft );
% Plot fit with data.
% figure( 'Name', 'untitled fit 1' );
h = plot( fitresult);
% legend( h, 'untitled fit 1', 's_d_or_HF vs. Nc_HF, Eo_HF', 'Location', 'NorthEast' );
% % Label axes
% xlabel Nc_HF
% ylabel Eo_HF
% zlabel s_d_or_HF
% grid on
% view( 70.8, 22.0 );

Sign in to comment.

Answers (1)

KSSV
KSSV on 4 Aug 2020
Edited: KSSV on 4 Aug 2020
This command:
h = plot( fitresult);
You specify a marker/ different color for both the functions.
h = plot( fitresult,'b'); % in one function
h = plot( fitresult,'r'); % in another function
  2 Comments
EM
EM on 4 Aug 2020
I get the following error:
Error using plot
No value was given for 'cb'. Name-value pair arguments require a
name followed by a value.
KSSV
KSSV on 4 Aug 2020
Use simply b.Read about plot in the documentation.

Sign in to comment.

Categories

Find more on Fit Postprocessing in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!