Skip to content
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

fix #975 Legend color (and width) is not matching that of curve in fi… #977

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,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);
%=============================================================================