Skip to content

Conversation

@gilbertogalvis
Copy link
Contributor

Case 1. When there is only one legend:

In this case I just let the location of the Plotly legend be similar to the location of the Matlab legend. I attach an example screenshot.

Screen Shot 2021-09-29 at 1 53 02 PM

Case 2: When there are multiple legends.

Before making changes to the code, fig2plotly does the following (see screenshot). As we can see, the error appears because the philosophy of plotly for the legends is different from MATLAB. In MATLAB we can place a legend for each plot. While Plotly what it does is configure a single legend that handles the total group of plots.

So, the current fig2plotly code places the Plotly legend according to the first MATLAB legend and there it places the information for all MATLAB legends.

Screen Shot 2021-09-29 at 1 53 54 PM

Updated code for this PR.

To solve the issue with multiple legends, I have updated the fig2plotly code and now it does the following

Screen Shot 2021-09-29 at 2 04 27 PM

here is the link to Chart-Studio https://chart-studio.plotly.com/~galvisgilberto/4574/mahalanobis/#/

Code example

load fisheriris

rng('default') % for reproducibility
Y = tsne(meas,'Algorithm','exact','Distance','mahalanobis');
subplot(2,2,1)
gscatter(Y(:,1),Y(:,2),species)
title('Mahalanobis')

rng('default') % for fair comparison
Y = tsne(meas,'Algorithm','exact','Distance','cosine');
subplot(2,2,2)
gscatter(Y(:,1),Y(:,2),species)
title('Cosine')

rng('default') % for fair comparison
Y = tsne(meas,'Algorithm','exact','Distance','chebychev');
subplot(2,2,3)
gscatter(Y(:,1),Y(:,2),species)
title('Chebychev')

rng('default') % for fair comparison
Y = tsne(meas,'Algorithm','exact','Distance','euclidean');
subplot(2,2,4)
gscatter(Y(:,1),Y(:,2),species)
title('Euclidean')

fig2plotly(gcf, 'offline', false);

@jackparmer jackparmer merged commit 5287af9 into master Oct 7, 2021
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.

3 participants