Skip to content

Commit

Permalink
fix #975 Legend color (and width) is not matching that of curve in fi… (
Browse files Browse the repository at this point in the history
  • Loading branch information
Nelson-numerical-software authored Oct 24, 2023
1 parent 16dba18 commit 95d7a9d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- [#940](http://github.com/Nelson-numerical-software/nelson/issues/940) title bar on dark theme on Windows.
- help viewer using dark theme.
- adjust position `xlabel` on `figure`.
- [#975](http://github.com/Nelson-numerical-software/nelson/issues/975) Legend color (and width) is not matching that of curve in figure.

## 0.7.9 (2023-09-18)

Expand Down
3 changes: 2 additions & 1 deletion modules/graphics/functions/legend.m
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@
lineHandles(indexLineHandles) = line('Visible', 'off', ...
'XData', [1, 4] * nunx, ...
'YData', [ypos,ypos], ...
'Color', children(i).Color, ...
'Color', children(i).Color, ...
'LineWidth', children(i).LineWidth, ...
'LineStyle', children(i).LineStyle);

indexLineHandles = indexLineHandles + 1;
Expand Down
39 changes: 39 additions & 0 deletions modules/graphics/tests/bug_github_issue_#975.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
%=============================================================================
% Copyright (c) 2017 Allan CORNET (Nelson)
%=============================================================================
% This file is part of the Nelson.
%=============================================================================
% LICENCE_BLOCK_BEGIN
% SPDX-License-Identifier: LGPL-3.0-or-later
% LICENCE_BLOCK_END
%=============================================================================
% <-- Issue URL -->
% https://github.com/Nelson-numerical-software/nelson/issues/975
% <-- Short Description -->
% Legend color is not matching that of curve in figure.
%=============================================================================
% <--ADV-CLI MODE-->
%=============================================================================
f = figure();
a = [0:0.5:5];
b = 2*a.^2 + 3*a -5;
c = 1.2*a.^2+4*a-3;
subplot(1,2,1)
plot(a,b,'-or','MarkerFaceColor','g','LineWidth',2)
xlabel('X'); ylabel('Y'); legend('Curve ','Location','NorthWest')
subplot(1,2,2)
plot(a,c,'--ok','MarkerFaceColor','c','LineWidth',2)
xlabel('X'); ylabel('Y'); legend('Curve 2','Location','NorthWest')
%=============================================================================
f = figure();
a = [0:0.5:5];
b = 2*a.^2 + 3*a -5;
plot(a,b,'-or','MarkerFaceColor','g','LineWidth', 3);
legend('Curve ','Location','NorthWest')
childrens = f.Children;
axe_legend = childrens(2);
line_legend = axe_legend.Children(2);
line_legend.Color = 'red';
assert_isequal(line_legend.Color, [1 0 0]);
assert_isequal(line_legend.LineWidth, 3);
%=============================================================================

0 comments on commit 95d7a9d

Please sign in to comment.