-
Notifications
You must be signed in to change notification settings - Fork 1
make install_font() own function for clarity, add unit tests, work on Windows, macOS and Linux #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
01e57a9
ac8303f
9946cd2
cdd5dda
2943f0a
636802a
490c550
b5a1f09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| name: matlab | ||
|
|
||
| on: | ||
| push: | ||
| paths: | ||
| - "**.m" | ||
| - ".github/workflows/ci.yml" | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
|
|
||
| jobs: | ||
|
|
||
| tests: | ||
| strategy: | ||
| fail-fast: true | ||
| matrix: | ||
| os: [ubuntu-latest] | ||
| matlab: [R2023b, R2025b] | ||
| include: | ||
| - os: macos-latest | ||
| matlab: R2025b | ||
| - os: windows-latest | ||
| matlab: R2025b | ||
|
|
||
| runs-on: ${{ matrix.os }} | ||
|
|
||
| timeout-minutes: 15 | ||
|
|
||
| steps: | ||
|
|
||
| - name: Install MATLAB | ||
| timeout-minutes: 10 | ||
| uses: matlab-actions/setup-matlab@v2 | ||
| with: | ||
| release: ${{ matrix.matlab }} | ||
| cache: true | ||
|
|
||
| - uses: actions/checkout@v6 | ||
|
|
||
| - name: Check Matlab code | ||
| uses: matlab-actions/run-build@v2 | ||
| with: | ||
| tasks: check | ||
|
|
||
| - name: Install font | ||
| uses: matlab-actions/run-build@v2 | ||
| with: | ||
| tasks: install | ||
|
|
||
| - name: Run Matlab tests | ||
| uses: matlab-actions/run-build@v2 | ||
| with: | ||
| tasks: test | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| *.swp | ||
| *.asv |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,22 +2,57 @@ | |||||
|
|
||||||
| DARK converts a standard light-themed plot to a dark color scheme. DARK is easy to use, simply run the command "dark" on your current plot to render it in a dark theme. Once converted you may continue to manipulate the plot as desired including zooming, panning, and modifying properties. | ||||||
|
|
||||||
| DARK uses only native functions common to MATLAB and GNU Octave without any dependencies on toolboxes or packages. Because of this it will likely run on most any version. It's been tested with MATLAB versions R2019b, R2020b, R2022b, and R2023b as well as GNU Octave versions 3.8.2, 4.4.0, 5.2.0, 6.4.0, 8.3.0, and 9.1.0. DARK has been tested on Windows 10 and Linux distros running Centos7, RHEL 8, and Ubuntu 22.04. | ||||||
| DARK uses only native functions common to MATLAB and GNU Octave without any dependencies on toolboxes or packages. | ||||||
| Because of this it will likely run on most any version. | ||||||
| It's been tested with MATLAB versions R2019b, R2020b, R2022b, R2023b, and R2026a | ||||||
| as well as GNU Octave versions 3.8.2, 4.4.0, 5.2.0, 6.4.0, 8.3.0, 9.1.0, and 11.1.0. | ||||||
| DARK has been tested on Windows 10, macOS,and Linux distros running Centos7, RHEL 8, and Ubuntu 22.04. | ||||||
|
||||||
| DARK has been tested on Windows 10, macOS,and Linux distros running Centos7, RHEL 8, and Ubuntu 22.04. | |
| DARK has been tested on Windows 10, macOS, and Linux distros running Centos7, RHEL 8, and Ubuntu 22.04. |
Copilot
AI
Mar 29, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "thme" should be "theme".
| It works the same way as DARK, simply run the command "hand" on your current plot to render it in a hand-drawn thme. | |
| It works the same way as DARK, simply run the command "hand" on your current plot to render it in a hand-drawn theme. |
Copilot
AI
Mar 29, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in README: "funtions" should be "functions".
| Similar to DARK, HAND is coded using funtions native to MATLAB and GNU Octave without any dependencies on toolboxes or packages, making it highly portable. | |
| Similar to DARK, HAND is coded using functions native to MATLAB and GNU Octave without any dependencies on toolboxes or packages, making it highly portable. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| function plan = buildfile | ||
|
|
||
| plan = buildplan(localfunctions); | ||
|
|
||
| plan("test") = matlab.buildtool.tasks.TestTask("test/"); | ||
| end | ||
|
|
||
| function checkTask(context) | ||
| root = context.Plan.RootFolder; | ||
|
|
||
| c = codeIssues(root, IncludeSubfolders=true); | ||
|
|
||
| if isempty(c.Issues) | ||
| fprintf('%d files checked OK with %s under %s\n', numel(c.Files), c.Release, root) | ||
| else | ||
| disp(c.Issues) | ||
| error("Errors found in " + join(c.Issues.Location, newline)) | ||
| end | ||
|
|
||
| end | ||
|
|
||
| function installTask(~) | ||
| assert(install_font(), "install font failed") | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,7 +50,7 @@ function dark(colors_in) | |
| % >> dark('bp'); | ||
| % | ||
|
|
||
| global colors | ||
| global colors %#ok<*GVMIS> | ||
|
|
||
| if nargin == 0 | ||
| colors = fetch_colortab(); | ||
|
|
@@ -70,12 +70,12 @@ function dark(colors_in) | |
| function draw_canvas() | ||
|
|
||
| % draw background | ||
| set(gca,'Color','black'); | ||
| set(gcf,'Color','black'); | ||
| set(gca,'zcolor','white'); | ||
| set(gca,'Color','black') | ||
| set(gcf,'Color','black') | ||
| set(gca,'zcolor','white') | ||
| if isoctave() | ||
| set(gca,'xcolor','white'); | ||
| set(gca,'ycolor','white'); | ||
| set(gca,'xcolor','white') | ||
| set(gca,'ycolor','white') | ||
| end | ||
|
|
||
| end % function | ||
|
|
@@ -100,25 +100,26 @@ function ml_graph_data() | |
| for kk = numel(h):-1:1 | ||
| cc = cc + 1; | ||
| index = rem(cc-1,size(colors,1)) + 1; | ||
| if isa(h(kk), 'matlab.graphics.chart.primitive.Line') | ||
| set(h(kk),'Color',colors(index,:)); | ||
| set(h(kk),'MarkerFaceColor',colors(index,:)); | ||
| set(h(kk),'MarkerEdgeColor',colors(index,:)); | ||
| elseif isa(h(kk), 'matlab.graphics.chart.primitive.Bar') | ||
| set(h(kk),'FaceColor',colors(index,:)); | ||
| set(h(kk),'EdgeColor','white'); | ||
| set(h(kk),'EdgeAlpha',0.5); | ||
| elseif isa(h(kk), 'matlab.graphics.chart.primitive.Stem') | ||
| set(h(kk),'Color',colors(index,:)); | ||
| set(h(kk),'MarkerFaceColor',colors(index,:)); | ||
| set(h(kk),'MarkerEdgeColor',colors(index,:)); | ||
| elseif isa(h(kk), 'matlab.graphics.primitive.Patch') | ||
| switch class(h(kk)) | ||
| case 'matlab.graphics.chart.primitive.Line' | ||
| set(h(kk),'Color',colors(index,:)) | ||
| set(h(kk),'MarkerFaceColor',colors(index,:)) | ||
| set(h(kk),'MarkerEdgeColor',colors(index,:)) | ||
|
Comment on lines
+103
to
+107
|
||
| case 'matlab.graphics.chart.primitive.Bar' | ||
| set(h(kk),'FaceColor',colors(index,:)) | ||
| set(h(kk),'EdgeColor','white') | ||
| set(h(kk),'EdgeAlpha',0.5) | ||
| case 'matlab.graphics.chart.primitive.Stem' | ||
| set(h(kk),'Color',colors(index,:)) | ||
| set(h(kk),'MarkerFaceColor',colors(index,:)) | ||
| set(h(kk),'MarkerEdgeColor',colors(index,:)) | ||
| case 'matlab.graphics.primitive.Patch' | ||
| celight = get(h(kk),'EdgeColor'); | ||
| cflight = get(h(kk),'FaceColor'); | ||
| set(h(kk),'EdgeColor',[1 1 1] - celight); | ||
| set(h(kk),'FaceColor',[1 1 1] - cflight); | ||
| elseif isa(h(kk), 'matlab.graphics.primitive.Text') | ||
| set(h(kk),'Color','w'); | ||
| set(h(kk),'EdgeColor',[1 1 1] - celight) | ||
| set(h(kk),'FaceColor',[1 1 1] - cflight) | ||
| case 'matlab.graphics.primitive.Text' | ||
| set(h(kk),'Color','w') | ||
| end | ||
| end | ||
|
|
||
|
|
@@ -136,28 +137,29 @@ function go_graph_data() | |
| index = rem(cc-1,size(colors,1)) + 1; | ||
| if isa(h, 'double') | ||
| % octave | ||
| if strcmpi(get(h(kk),'type'),'line') | ||
| set(h(kk),'Color',colors(index,:)); | ||
| elseif strcmpi(get(h(kk),'type'),'hggroup') | ||
| switch lower(get(h(kk),'type')) | ||
| case 'line' | ||
| set(h(kk),'Color',colors(index,:)) | ||
| case 'hggroup' | ||
| if isfield(get(h(kk)),'bargroup') | ||
| % bar plot | ||
| set(h(kk),'FaceColor',colors(index,:)); | ||
| set(h(kk),'EdgeColor','white'); | ||
| set(h(kk),'FaceColor',colors(index,:)) | ||
| set(h(kk),'EdgeColor','white') | ||
| else | ||
| % stem plot | ||
| set(h(kk),'Color',colors(index,:)); | ||
| set(h(kk),'MarkerEdgeColor',colors(index,:)); | ||
| set(h(kk),'Color',colors(index,:)) | ||
| set(h(kk),'MarkerEdgeColor',colors(index,:)) | ||
| if isnumeric(get(h(kk)).markerfacecolor) | ||
| set(h(kk),'MarkerFaceColor',colors(index,:)); | ||
| set(h(kk),'MarkerFaceColor',colors(index,:)) | ||
| end | ||
| end | ||
| elseif strcmpi(get(h(kk),'type'),'patch') | ||
| case 'patch' | ||
| celight = get(h(kk),'EdgeColor'); | ||
| cflight = get(h(kk),'FaceColor'); | ||
| set(h(kk),'EdgeColor',[1 1 1] - celight); | ||
| set(h(kk),'FaceColor',[1 1 1] - cflight); | ||
| elseif strcmpi(get(h(kk),'type'),'text') | ||
| set(h(kk),'Color','w'); | ||
| set(h(kk),'EdgeColor',[1 1 1] - celight) | ||
| set(h(kk),'FaceColor',[1 1 1] - cflight) | ||
| case 'text' | ||
| set(h(kk),'Color','w') | ||
| end % hggroup | ||
| end % double | ||
| end % kk | ||
|
|
@@ -179,9 +181,9 @@ function ml_label_axes() | |
| tt = get(gca,'title'); | ||
| xx = get(gca,'xaxis'); | ||
| yy = get(gca,'yaxis'); | ||
| set(tt,'Color','white'); | ||
| set(xx,'Color','white'); | ||
| set(yy,'Color','white'); | ||
| set(tt,'Color','white') | ||
| set(xx,'Color','white') | ||
| set(yy,'Color','white') | ||
|
|
||
| end % function | ||
|
|
||
|
|
@@ -192,10 +194,10 @@ function go_label_axes() | |
| xx = get(gca,'xlabel'); | ||
| yy = get(gca,'ylabel'); | ||
| zz = get(gca,'zlabel'); | ||
| set(tt,'Color','white'); | ||
| set(xx,'Color','white'); | ||
| set(yy,'Color','white'); | ||
| set(zz,'Color','white'); | ||
| set(tt,'Color','white') | ||
| set(xx,'Color','white') | ||
| set(yy,'Color','white') | ||
| set(zz,'Color','white') | ||
|
|
||
| end % function | ||
|
|
||
|
|
@@ -241,9 +243,9 @@ function go_handle_legend() | |
| props = get(h(end)); | ||
| if isfield(props,'displayname') && ~isempty(props.displayname) | ||
| lgd = legend; | ||
| set(lgd,'Color','black'); | ||
| set(lgd,'EdgeColor','white'); | ||
| set(lgd,'TextColor','white'); | ||
| set(lgd,'Color','black') | ||
| set(lgd,'EdgeColor','white') | ||
| set(lgd,'TextColor','white') | ||
| end | ||
|
|
||
| end % function | ||
|
|
@@ -262,7 +264,7 @@ function ml_handle_colorbar() | |
|
|
||
| cb = get(gca,'Colorbar'); | ||
| if ~isempty(cb) | ||
| set(cb,'Color','white'); | ||
| set(cb,'Color','white') | ||
| end | ||
|
|
||
| end % function | ||
|
|
@@ -273,8 +275,8 @@ function go_handle_colorbar() | |
| if isfield(props,'__colorbar_handle__') | ||
| cb = get(gca,'__colorbar_handle__'); | ||
| if ~isempty(cb) | ||
| set(cb,'ycolor','white'); | ||
| set(cb,'fontsize',12); | ||
| set(cb,'ycolor','white') | ||
| set(cb,'fontsize',12) | ||
| end | ||
| end | ||
|
|
||
|
|
@@ -292,22 +294,22 @@ function finish_up() | |
|
|
||
| function ml_finish_up() | ||
|
|
||
| set(gca,'GridColor','white'); | ||
| set(gca,'GridAlpha',0.3); | ||
| set(gca,'GridColor','white') | ||
| set(gca,'GridAlpha',0.3) | ||
|
|
||
| end % function | ||
|
|
||
| function go_finish_up() | ||
|
|
||
| props = get(gca); | ||
| if isfield(props,'gridcolor') | ||
| set(gca,'GridColor','white'); | ||
| set(gca,'GridColor','white') | ||
| end | ||
| if isfield(props,'gridalpha') | ||
| set(gca,'GridAlpha',0.3); | ||
| set(gca,'GridAlpha',0.3) | ||
| end | ||
| if isfield(props,'fontsize') | ||
| set(gca,'FontSize',14); | ||
| set(gca,'FontSize',14) | ||
| end | ||
|
|
||
| end % function | ||
|
|
@@ -318,7 +320,7 @@ function go_finish_up() | |
| fc = fieldnames(colortab_base()); | ||
| c = ''; | ||
| for kk = 1:numel(fc) | ||
| c = [c fc{kk}]; | ||
| c = [c fc{kk}]; %#ok<*AGROW> | ||
| end | ||
| else | ||
| c = colors_in; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This workflow runs only on
push. If the intent is to validate pull requests, add apull_requesttrigger as well so CI executes for PRs before merge.