Skip to content

docs - swarmchart #435

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

Closed
danton267 opened this issue Oct 22, 2021 · 1 comment
Closed

docs - swarmchart #435

danton267 opened this issue Oct 22, 2021 · 1 comment

Comments

@danton267
Copy link
Member

danton267 commented Oct 22, 2021

None of these work properly: https://github.com/plotly/plotly.matlab-docs/blob/main/matlab/2021-08-04-violin.md

gilbertogalvis pushed a commit that referenced this issue Nov 1, 2021
@gilbertogalvis
Copy link
Contributor

This issues was fixed by PR #468. In this sense, it adds the swarmchart functionality to matlab_plotly.

Example 1

x = [ones(1,500) 2*ones(1,500) 3*ones(1,500)];
y1 = 2 * randn(1,500);
y2 = 3 * randn(1,500) + 5;
y3 = 5 * randn(1,500) + 5;
y = [y1 y2 y3];
swarmchart(x,y)

fig2plotly(gcf);

Screen Shot 2021-11-01 at 12 02 07 PM

Example 2

x1 = ones(1,500);
x2 = 2 * ones(1,500);
x3 = 3 * ones(1,500);
y1 = 2 * randn(1,500);
y2 = [randn(1,250) randn(1,250) + 4];
y3 = 5 * randn(1,500) + 5;

swarmchart(x1,y1,5)
hold on
swarmchart(x2,y2,5)
swarmchart(x3,y3,5)
hold off

fig2plotly(gcf);

Screen Shot 2021-11-01 at 12 02 47 PM

Example 3

tbl = readtable(fullfile(matlabroot,'examples','matlab','data','BicycleCounts.csv'));

daynames = ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday"];
x = categorical(tbl.Day,daynames);
y = tbl.Total;
swarmchart(x,y,'.');

fig2plotly(gcf);

Screen Shot 2021-11-01 at 12 03 27 PM

Example 4

tbl = readtable(fullfile(matlabroot,'examples','matlab','data','BicycleCounts.csv'));
daynames = ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday"];
x = categorical(tbl.Day,daynames);
y = tbl.Total;
c = hour(tbl.Timestamp);
swarmchart(x,y,20,c,'filled');

fig2plotly(gcf);

Screen Shot 2021-11-01 at 12 03 52 PM

Example 5

tbl = readtable(fullfile(matlabroot,'examples','matlab','data','BicycleCounts.csv'));
daynames = ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday"];
x = categorical(tbl.Day,daynames);
y = tbl.Total;
c = hour(tbl.Timestamp);
s = swarmchart(x,y,5,c);

fig2plotly(gcf);

Screen Shot 2021-11-01 at 12 04 12 PM

Example 6

tbl = readtable(fullfile(matlabroot,'examples','matlab','data','BicycleCounts.csv'));
daynames = ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday"];
x = categorical(tbl.Day,daynames);
y = tbl.Total;
c = hour(tbl.Timestamp);
s = swarmchart(x,y,5,c);

s.XJitter = 'rand';
s.XJitterWidth = 0.5;

fig2plotly(gcf);

Screen Shot 2021-11-01 at 12 04 35 PM

Example 7

x1 = ones(1,500);
x2 = 2 * ones(1,500);
x = [x1 x2];
y1 = 2 * randn(1,500);
y2 = [randn(1,250) randn(1,250) + 4];
y = [y1 y2];
swarmchart(x,y,'filled','MarkerFaceAlpha',0.5,'MarkerEdgeAlpha',0.5)

fig2plotly(gcf);

Screen Shot 2021-11-01 at 12 04 54 PM

Example 8

tbl = readtable(fullfile(matlabroot,'examples','matlab','data','BicycleCounts.csv'));

daynames = ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday"];
x = categorical(tbl.Day,daynames);
yEast = tbl.Eastbound;
yWest = tbl.Westbound;

tiledlayout('flow')
ax1 = nexttile;
y = tbl.Eastbound;
swarmchart(ax1,x,y,'.');

fig2plotly(gcf);

Screen Shot 2021-11-01 at 12 05 23 PM

Example 9

(fullfile(matlabroot,'examples','matlab','data','BicycleCounts.csv'));

daynames = ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday"];
x = categorical(tbl.Day,daynames);
yEast = tbl.Eastbound;
yWest = tbl.Westbound;

tiledlayout('flow')
ax1 = nexttile;
y = tbl.Eastbound;
swarmchart(ax1,x,y,'.');

ax2 = nexttile;
y = tbl.Westbound;
s = swarmchart(ax2,x,y,'.');

fig2plotly(gcf);

Screen Shot 2021-11-01 at 12 05 50 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

No branches or pull requests

2 participants