Thanks to visit codestin.com
Credit goes to github.com

Skip to content

adding spider_plot package funcionality to matlab_plotly #411

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

Conversation

gilbertogalvis
Copy link
Contributor

This PR adds the functionality offered by the spider_plot package to matlab_plotly. This has been a lot of hard work because I had to code everything from scratch to make this work.

Specifically, I developed a whole file which I called updateSpiderPlot.m, which in turn contains at least 10 functions internally. For this reason, this new update on my part took time.

Next I will share a series of examples with this functionality. These examples are those offered by MATLAB MathWorks in the link I shared.

Example 1

% Example 1: Minimal number of arguments. All non-specified, optional arguments are set to their default values. Axes labels and limits are automatically generated and set.

% Initialize data points
D1 = [5 3 9 1 2];
D2 = [5 8 7 2 9];
D3 = [8 2 1 4 6];
P = [D1; D2; D3];

% Delete variable in workspace if exists
if exist('s', 'var')
    delete(s);
end

% Spider plot
s = spider_plot_class(P);

% Legend properties
s.LegendLabels = {'D1', 'D2', 'D3'};
s.LegendHandle.Location = 'northeastoutside';

Screen Shot 2021-10-14 at 7 21 24 PM

Example 2

% Example 2: Manually setting the axes limits. All non-specified, optional arguments are set to their default values.

% Initialize data points
D1 = [5 3 9 1 2];
D2 = [5 8 7 2 9];
D3 = [8 2 1 4 6];
P = [D1; D2; D3];

% Delete variable in workspace if exists
if exist('s', 'var')
    delete(s);
end

% Spider plot
s = spider_plot_class(P);

% Spider plot properties
s.AxesLimits = [1, 2, 1, 1, 1; 10, 8, 9, 5, 10]; % [min axes limits; max axes limits]
s.AxesPrecision = [0, 1, 1, 1, 1];

s.LegendLabels = {'D1', 'D2', 'D3'};

Screen Shot 2021-10-14 at 7 21 56 PM

Example 3

% Example 3: Set fill option on. The fill transparency can be adjusted.

% Initialize data points
D1 = [5 3 9 1 2];
D2 = [5 8 7 2 9];
D3 = [8 2 1 4 6];
P = [D1; D2; D3];

% Delete variable in workspace if exists
if exist('s', 'var')
    delete(s);
end

% Spider plot
s = spider_plot_class(P);

% Spider plot properties
s.AxesLabels = {'S1', 'S2', 'S3', 'S4', 'S5'};
s.AxesInterval = 2;
s.FillOption = {'on', 'on', 'off'};
s.FillTransparency = [0.2, 0.1, 0.1];

Screen Shot 2021-10-14 at 7 22 21 PM

Example 4

% Example 4: Maximum number of arguments.

% Initialize data points
D1 = [5 3 9 1 2];
D2 = [5 8 7 2 9];
D3 = [8 2 1 4 6];
P = [D1; D2; D3];

% Delete variable in workspace if exists
if exist('s', 'var')
    delete(s);
end

% Spider plot
s = spider_plot_class(P);

% Spider plot properties
s.AxesLabels = {'S1', 'S2', 'S3', 'S4', 'S5'};
s.AxesInterval = 4;
s.AxesPrecision = 0;
s.AxesDisplay = 'one';
s.AxesLimits = [1, 2, 1, 1, 1; 10, 8, 9, 5, 10];
s.FillOption = 'on';
s.FillTransparency =  0.2;
s.Color = [1, 0, 0; 0, 1, 0; 0, 0, 1];
s.LineStyle = '--';
s.LineWidth = 3;
s.LineTransparency = 1;
s.Marker =  'd';
s.MarkerSize = 10;
s.MarkerTransparency = 1;
s.AxesFont = 'Times New Roman';
s.LabelFont = 'Times New Roman';
s.AxesFontSize = 12;
s.LabelFontSize = 10;
s.Direction = 'clockwise';
s.AxesDirection = {'reverse', 'normal', 'normal', 'normal', 'normal'};
s.AxesLabelsOffset = 0;
s.AxesScaling = 'linear';
s.AxesColor = [0.6, 0.6, 0.6];
s.AxesLabelsEdge = 'none';
s.AxesOffset = 1;
s.LegendLabels = {'D1', 'D2', 'D3'};
s.LegendHandle.Location = 'northeastoutside';

Screen Shot 2021-10-14 at 7 22 44 PM

Example 5

% Example 5: Excel-like radar charts.

% Initialize data points
D1 = [5 0 3 4 4];
D2 = [2 1 5 5 4];
P = [D1; D2];

% Delete variable in workspace if exists
if exist('s', 'var')
    delete(s);
end

% Spider plot
s = spider_plot_class(P);

% Spider plot properties
s.AxesInterval = 5;
s.AxesPrecision = 0;
s.AxesDisplay = 'one';
s.AxesLimits = [0, 0, 0, 0, 0; 5, 5, 5, 5, 5];
s.FillOption = 'on';
s.FillTransparency = 0.1;
s.Color = [139, 0, 0; 240, 128, 128]/255;
s.LineWidth = 4;
s.Marker = 'none';
s.AxesFontSize = 14;
s.LabelFontSize = 10;
s.AxesColor = [0.8, 0.8, 0.8];
s.AxesLabelsEdge = 'none';
s.LegendLabels = {'D1', 'D2'};
title('Excel-like Radar Chart',...
    'FontSize', 14);

Screen Shot 2021-10-14 at 7 23 09 PM

Example 6

% Example 6: Logarithimic scale on all axes. Axes limits and axes intervals are automatically set to factors of 10.

% Initialize data points
D1 = [5 3 9 1 1];
D2 = [5 8 7 2 10];
D3 = [8 2 1 4 100];
P = [D1; D2; D3];

% Delete variable in workspace if exists
if exist('s', 'var')
    delete(s);
end

% Spider plot
s = spider_plot_class(P);

% Spider plot properties
s.AxesInterval = 2;
s.AxesPrecision = 0;
s.AxesFontSize = 10;
s.AxesLabels = {'Linear Scale', 'Linear Scale', 'Linear Scale', 'Linear Scale', 'Logarithimic Scale'};
s.AxesScaling = {'linear', 'linear', 'linear', 'linear', 'log'};
s.AxesLimits = [1, 1, 1, 1, 1; 10, 10, 10, 10, 100];
s.LegendLabels = {'D1', 'D2', 'D3'};

Screen Shot 2021-10-14 at 7 23 28 PM

Example 8

% Example 8: Spider plot with values only on data points.

% Initialize data points
close all;
D1 = [1 3 4 1 2];
D2 = [5 8 7 5 9];
P = [D1; D2];

% Spider plot
s = spider_plot_class(P);
s.AxesLimits = [1, 1, 1, 1, 1; 10, 10, 10, 10, 10];
s.AxesDisplay = 'data';
s.AxesLabelsOffset = 0.1;
s.AxesFontColor = [0, 0, 1; 1, 0, 0];

% Legend properties
s.LegendLabels = {'D1', 'D2'};
s.LegendHandle.Location = 'northeastoutside';

Screen Shot 2021-10-14 at 7 23 52 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants