Info
This question is closed. Reopen it to edit or answer.
How to add clabel when not using the contour function? [Auto generated code from curvefitting toolbox]
1 view (last 30 days)
Show older comments
Hello,
I have auto generated following code using the curvefitting toolbox:
function [fitresult, gof] = createContour(X, Y, Z)
%CREATEFIT1(X,Y,Z)
% Create a fit.
%
% Data for 'untitled fit 1' fit:
% X Input : X
% Y Input : Y
% Z Output: Z
% 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 22-Jan-2018 21:18:31
%%Fit: 'untitled fit 1'.
[xData, yData, zData] = prepareSurfaceData( X, Y, Z );
% Set up fittype and options.
ft = 'linearinterp';
% Fit model to data.
[fitresult, gof] = fit( [xData, yData], zData, ft, 'Normalize', 'on' );
% Create a figure for the plots.
figure( 'Name', 'untitled fit 1' );
% Make contour plot.
subplot( 1, 1, 1 );
h = plot( fitresult, [xData, yData], zData, 'Style', 'Contour');
% legend( h, 'untitled fit 1', 'Z vs. X, Y', 'Location', 'NorthEast' );
% Label axes
clabel([],zData)
xlabel X
ylabel Y
grid on
I couldn't use the contour function, because it expect a 'at least 2x2 matrix'. I am using single vectors, and then combining them using the Curvefitting toolbox to give me a surface (e.g. X=30x1,Y=30x1, Z=30x1 rowvector). From there I generate the contourplot using the button in the top left toolbar. Afterwards I autogenerated the code above, and deleted the Surfaceplot, because I am only interested in the contour plot for now. I changed the subplot to (1,1,1) to fill the whole figure.
Now my question is: how do I add the nice clabels showing me the values of Z in nice colored text?
Thank you in advance.
Update: I found this snippet:
set(h, 'Fill', 'off', 'LineColor', 'auto')
Which is nice. Follow up question: How do I add the values as text, and maybe even change linestyle (to be better readable for colorblind/or b/w copies).
Using MatLab R2015b
0 Comments
Answers (0)
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!