Skip to content

Commit

Permalink
added gifs
Browse files Browse the repository at this point in the history
  • Loading branch information
Julie-Fabre committed Nov 2, 2023
1 parent 9fd5c6e commit 0e2a649
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 19 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ prettify_matlab doesn't use any of MATLAB's add-on toolboxes and doesn't have an
### Prettify plots

Run `prettify_plot;` to prettify your current figure (includes all subplots). Includes options to modify the background color, text size and homogenize x and y limits across plots.
<img src="./images/prettify_plot.png" width="100%">
<img src="./images/prettify_plot.gif" width="100%">

### Prettify code

Run `prettify_current_code;` to prettify your current script open in the MATLAB editor. All code editing rules are stored in the `formatRules.xml` file, where they can easily be changed.
<img src="./images/prettify_code.png" width="100%">
<img src="./images/prettify_code_4.gif" width="100%">

### Prettify colors
#### Colorblind simulator
Expand Down
49 changes: 36 additions & 13 deletions examples/uglyCodeExample.m
Original file line number Diff line number Diff line change
@@ -1,13 +1,36 @@
function [f,r,t]=uglyCodeExample(n)
%comment
if n<0,error('Negative!');elseif isinf(n),error('Too big!'),end
if ~(isnumeric(n )&&isscalar( n)&&mod(n,1)== 0),error('Not a pos int.');end,r=1;for i=1:n;
r=r*i;end
f=0;
g=1;for j=1:n;
t=f;
f=f+g;
g=t;end
t=0;for h=1:n;
t=t+h;end,k=3;while k<n,for m=2:floor(sqrt(k)),if mod(k,m)==0,break,end;if m==floor(sqrt(k ) ),disp(['Prime ',num2str(k)]),end,k=k+1;end
end
function [f, r, t] = uglyCodeExample(n)
% comment
if n < 0
error('Negative!');
elseif isinf(n)
error('Too big!');
end
if ~(isnumeric(n)&& isscalar(n)&& mod(n, 1)== 0)
error('Not a pos int.');
end
r = 1;
for i = 1:n
r = r * i;
end
f = 0;
g = 1;
for j = 1:n
t = f;
f = f + g;
g = t;
end
t = 0;
for h = 1:n
t = t + h;
end
k = 3;
while k < n
for m = 2:floor(sqrt(k))
if mod(k, m)== 0
break
end
if m == floor(sqrt(k)), disp(['Prime ', num2str(k)])
end
k = k + 1;
end
end
2 changes: 1 addition & 1 deletion examples/uglyPlot.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
y_cot = cot(x); % Cotangent values

% Create a new figure
figure;
figure(1); clf;

% First subplot: sine curve
subplot(2, 2, 1);
Expand Down
Binary file added images/prettify_code_4.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/prettify_plot.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions prettify_plot/prettify_plot.m
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function prettify_plot(sameXLimits, sameYLimits, figureColor, legendAsTxt, title
thisAx = all_axes(iAx);
currAx = currFig.Children(thisAx);
if ~isempty(currAx)
try
%try
if ismember(sameXLimits, {'all'})
set(currAx, 'Xlim', [min(min(xlims_subplot)), max(max(xlims_subplot))]);
end
Expand All @@ -184,8 +184,8 @@ function prettify_plot(sameXLimits, sameYLimits, figureColor, legendAsTxt, title
if ismember(sameYLimits, {'col'})
set(currAx, 'Ylim', col_ylims{pos_subplot(iAx, 1) == col_subplots});
end
catch
end
%catch
%end
end
% set legend position
if ~isempty(currAx.Legend)
Expand Down

0 comments on commit 0e2a649

Please sign in to comment.