Changing the color of a 3D plot

40 vues (au cours des 30 derniers jours)
EM
EM le 4 Août 2020
Commenté : KSSV le 4 Août 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 commentaires
KSSV
KSSV le 4 Août 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 le 4 Août 2020
Modifié(e) : Rik le 4 Août 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 );

Connectez-vous pour commenter.

Réponses (1)

KSSV
KSSV le 4 Août 2020
Modifié(e) : KSSV le 4 Août 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 commentaires
EM
EM le 4 Août 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 le 4 Août 2020
Use simply b.Read about plot in the documentation.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by