Code covered by the BSD License  

Highlights from
GTL jetfuel_ternplot with neural network

image thumbnail

GTL jetfuel_ternplot with neural network

by

 

This is an upgrade of the ternplot code written by Carl Sandrock (ID#2299).

terncontour(A, B, C, Z, I)
function [Hcl, Hha] = terncontour(A, B, C, Z, I)
majors = 10;

[~,v]=size(Z);

if nargin < 4
    Z = C;
    C = 1 - (A+B);
end;

if nargin < 5
    I=20;
end;

[fA, fB, fC] = fractions(A, B, C);
[x, y] = terncoords(fA, fB, fC);

% Sort data points in x order
[x, i] = sort(x);
y = y(i);
Z = Z(i);

% Now we have X, Y, Z as vectors. 
% use meshgrid to generate a grid
Ngrid = 100;
xr = linspace(min(x), max(x), Ngrid);
yr = linspace(min(y), max(y), Ngrid);
[xg ,yg] = meshgrid(xr, yr);

% ...then use griddata to get a plottable array
zg = griddata(x, y, Z, xg, yg, 'cubic');

[hold_state, cax, next] = ternaxes(majors);

% plot data
if v==1
    [Cl, Ha] = contour(xg, yg, zg, I, 'k-');
else [Cl, Ha] = contourf(xg, yg, zg, I, 'k-');
end

clabel(Cl, Ha);  %,'FontSize',5,'LabelSpacing',35,'Rotation',0,'Color','g','Edgecolor',[.7 .7 .7]),'BackgroundColor',[1 1 .6],'Color','r'


if nargout > 0
    Hcl=Cl;
    Hha=Ha;
end

if ~hold_state
    set(gca,'dataaspectratio',[1 1 1]), axis off; set(cax,'NextPlot',next);
end
view(180, -90);

Contact us