Skip to content

Instantly share code, notes, and snippets.

@neenjaw
Created March 23, 2018 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neenjaw/e96cd6889bbe09d238b8143f63fe0a0c to your computer and use it in GitHub Desktop.
Save neenjaw/e96cd6889bbe09d238b8143f63fe0a0c to your computer and use it in GitHub Desktop.
Matlab arc graph
s = 763; % actual score
smin = 250.0; %min FICO
smax = 900.0; %max FICO
%aesthetic constants
k = 0.78;
k2 = (k+1.0)/2.0;
theta0=28.0; %the big arc covers 360-2*theta0 degrees
%the big arc
theta = [theta0:0.1:360.0-theta0] - 90.0;
x = cosd(theta);
y = sind(theta);
%arclength of the arc corresponding to score, in degrees
arcl = (s - smin)/(smax - smin) * (360.0 - 2*theta0);
%score arc
th2 = -[0:0.1:arcl] - 90.0 - theta0;
x2=k2*cosd(th2);
y2=k2*sind(th2);
%line ends drawing function
cap = @(th, k) plot([cosd(th) cosd(th)*k], [sind(th), sind(th)*k]);
%drawing
clf
axis([-1 1 -1 1]);
axis equal;
plot(x, y, k*x, k*y);
hold on
cap(-90.0-theta0, k);
cap(-90.0+theta0, k);
plot(x2, y2);
plot(x2(end), y2(end), 'o');
text(0,0,sprintf('%d',s),'FontSize',20, 'HorizontalAlignment', 'center');
disp('Done.');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment