Skip to content

Commit

Permalink
fix #814 scatter plot
Browse files Browse the repository at this point in the history
  • Loading branch information
Nelson-numerical-software committed Nov 2, 2023
1 parent 287420b commit f9fb4e9
Show file tree
Hide file tree
Showing 21 changed files with 54,236 additions and 132 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Added

- `scatter` Scatter plot.
- `stem` Plot discrete sequence data.
- `stairs` Stairstep graph.

Expand Down
18 changes: 5 additions & 13 deletions modules/graphics/functions/colstyle.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@
orig_t = style;
while (~giveup && length(style)>0)
giveup = 1;
if (matchit(style,colorset()))
[colorspec, style] = parseit(style,colorset);
if (matchit(style, getColorShortNameList()))
[colorspec, style] = parseit(style, getColorShortNameList());
giveup = 0;
end;
if (matchit(style,markerset()))
[markerspec, style] = parseit(style,markerset);
if (matchit(style, getMarkerNameList()))
[markerspec, style] = parseit(style, getMarkerNameList());
giveup = 0;
end
if (matchit(style,styleset()))
[linespec, style] = parseit(style,styleset);
[linespec, style] = parseit(style, styleset());
giveup = 0;
end
end
Expand Down Expand Up @@ -94,18 +94,10 @@
t(1:length(b)) = [];
end
%=============================================================================
function c = colorset()
c = {'y','m','c','r','g','b','w','k'};
end
%=============================================================================
function c = styleset()
c = {'--',':','-.','-'};
end
%=============================================================================
function c = markerset()
c = {'+','o','*','.','x','square','s','diamond','d','^','v','>','<'};
end
%=============================================================================
function b = stcmp(source,pattern)
b = zeros(size(source), 'logical');
for i=1:numel(source)
Expand Down
49 changes: 0 additions & 49 deletions modules/graphics/functions/plot.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,55 +106,6 @@
end
end
%=============================================================================
function color = getColorAndUpdateIndex(go)
colorOrder = go.ColorOrder;
if isempty (colorOrder)
color = [0 0 0];
return;
end
colorIndex = go.ColorOrderIndex;
nbColors = size (colorOrder, 1);
colorIndex = mod (colorIndex, nbColors);
if (colorIndex == 0)
colorIndex = nbColors;
elseif (colorIndex < 0)
colorIndex = 1;
end
color = colorOrder(colorIndex, :);
if (colorIndex >= nbColors)
colorIndex = colorIndex + 1;
colorIndex = mod (colorIndex, nbColors);
if (colorIndex == 0)
colorIndex = 1;
end
lineStyleOrderIndex = go.LineStyleOrderIndex;
go.LineStyleOrderIndex = lineStyleOrderIndex + 1;
else
colorIndex = colorIndex + 1;
end
go.ColorOrderIndex = colorIndex;
end
%=============================================================================
function lineStyle = getLineStyleAndUpdateIndex(go)
lineStyleOrder = go.LineStyleOrder;
if isempty (lineStyleOrder)
lineStyle = '-';
return;
end
if ischar(lineStyleOrder)
lineStyleOrder = cellstr(lineStyleOrder);
end
LineStyleOrderIndex = go.LineStyleOrderIndex;
numberOfStyles = size(lineStyleOrder, 1);
LineStyleOrderIndex = mod (LineStyleOrderIndex, numberOfStyles);
if (LineStyleOrderIndex == 0)
LineStyleOrderIndex = numberOfStyles;
elseif (LineStyleOrderIndex < 0)
LineStyleOrderIndex = 1;
end
lineStyle = lineStyleOrder{LineStyleOrderIndex};
end
%=============================================================================
function k = plotVector(go, x, y, lineProperties)
if isgraphics(go, 'hggroup')
ax = ancestor(go, 'axes');
Expand Down
49 changes: 0 additions & 49 deletions modules/graphics/functions/plot3.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,55 +120,6 @@
end
end
%=============================================================================
function color = getColorAndUpdateIndex(go)
colorOrder = go.ColorOrder;
if isempty (colorOrder)
color = [0 0 0];
return;
end
colorIndex = go.ColorOrderIndex;
nbColors = size (colorOrder, 1);
colorIndex = mod (colorIndex, nbColors);
if (colorIndex == 0)
colorIndex = nbColors;
elseif (colorIndex < 0)
colorIndex = 1;
end
color = colorOrder(colorIndex, :);
if (colorIndex >= nbColors)
colorIndex = colorIndex + 1;
colorIndex = mod (colorIndex, nbColors);
if (colorIndex == 0)
colorIndex = 1;
end
lineStyleOrderIndex = go.LineStyleOrderIndex;
go.LineStyleOrderIndex = lineStyleOrderIndex + 1;
else
colorIndex = colorIndex + 1;
end
go.ColorOrderIndex = colorIndex;
end
%=============================================================================
function lineStyle = getLineStyleAndUpdateIndex(go)
lineStyleOrder = go.LineStyleOrder;
if isempty (lineStyleOrder)
lineStyle = '-';
return;
end
if ischar(lineStyleOrder)
lineStyleOrder = cellstr(lineStyleOrder);
end
LineStyleOrderIndex = go.LineStyleOrderIndex;
numberOfStyles = size(lineStyleOrder, 1);
LineStyleOrderIndex = mod (LineStyleOrderIndex, numberOfStyles);
if (LineStyleOrderIndex == 0)
LineStyleOrderIndex = numberOfStyles;
elseif (LineStyleOrderIndex < 0)
LineStyleOrderIndex = 1;
end
lineStyle = lineStyleOrder{LineStyleOrderIndex};
end
%=============================================================================
function hl = plotVector(go, x, y, z, lineProperties)
if isgraphics(go, 'hggroup')
ax = ancestor(go, 'axes');
Expand Down
39 changes: 39 additions & 0 deletions modules/graphics/functions/private/getColorAndUpdateIndex.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
%=============================================================================
% Copyright (c) 2016-present Allan CORNET (Nelson)
%=============================================================================
% This file is part of the Nelson.
%=============================================================================
% LICENCE_BLOCK_BEGIN
% SPDX-License-Identifier: LGPL-3.0-or-later
% LICENCE_BLOCK_END
%=============================================================================
function color = getColorAndUpdateIndex(go)
colorOrder = go.ColorOrder;
if isempty (colorOrder)
color = [0 0 0];
return;
end
colorIndex = go.ColorOrderIndex;
nbColors = size (colorOrder, 1);
colorIndex = mod (colorIndex, nbColors);
if (colorIndex == 0)
colorIndex = nbColors;
elseif (colorIndex < 0)
colorIndex = 1;
end
color = colorOrder(colorIndex, :);
if (colorIndex >= nbColors)
colorIndex = colorIndex + 1;
colorIndex = mod (colorIndex, nbColors);
if (colorIndex == 0)
colorIndex = 1;
end
lineStyleOrderIndex = go.LineStyleOrderIndex;
go.LineStyleOrderIndex = lineStyleOrderIndex + 1;
else
colorIndex = colorIndex + 1;
end
go.ColorOrderIndex = colorIndex;
end
%=============================================================================

13 changes: 13 additions & 0 deletions modules/graphics/functions/private/getColorShortNameList.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
%=============================================================================
% Copyright (c) 2016-present Allan CORNET (Nelson)
%=============================================================================
% This file is part of the Nelson.
%=============================================================================
% LICENCE_BLOCK_BEGIN
% SPDX-License-Identifier: LGPL-3.0-or-later
% LICENCE_BLOCK_END
%=============================================================================
function l = getColorShortNameList()
l = {'y','m','c','r','g','b','w','k'};
end
%=============================================================================
30 changes: 30 additions & 0 deletions modules/graphics/functions/private/getLineStyleAndUpdateIndex.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
%=============================================================================
% Copyright (c) 2016-present Allan CORNET (Nelson)
%=============================================================================
% This file is part of the Nelson.
%=============================================================================
% LICENCE_BLOCK_BEGIN
% SPDX-License-Identifier: LGPL-3.0-or-later
% LICENCE_BLOCK_END
%=============================================================================
function lineStyle = getLineStyleAndUpdateIndex(go)
lineStyleOrder = go.LineStyleOrder;
if isempty (lineStyleOrder)
lineStyle = '-';
return;
end
if ischar(lineStyleOrder)
lineStyleOrder = cellstr(lineStyleOrder);
end
LineStyleOrderIndex = go.LineStyleOrderIndex;
numberOfStyles = size(lineStyleOrder, 1);
LineStyleOrderIndex = mod (LineStyleOrderIndex, numberOfStyles);
if (LineStyleOrderIndex == 0)
LineStyleOrderIndex = numberOfStyles;
elseif (LineStyleOrderIndex < 0)
LineStyleOrderIndex = 1;
end
lineStyle = lineStyleOrder{LineStyleOrderIndex};
end
%=============================================================================

13 changes: 13 additions & 0 deletions modules/graphics/functions/private/getMarkerNameList.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
%=============================================================================
% Copyright (c) 2016-present Allan CORNET (Nelson)
%=============================================================================
% This file is part of the Nelson.
%=============================================================================
% LICENCE_BLOCK_BEGIN
% SPDX-License-Identifier: LGPL-3.0-or-later
% LICENCE_BLOCK_END
%=============================================================================
function l = getMarkerNameList()
l = {'+','o','*','.','x','square','s','diamond','d','^','v','>','<', 'pentagram', 'p', 'hexagram', 'h'};
end
%=============================================================================
Loading

0 comments on commit f9fb4e9

Please sign in to comment.