plotly / plotly_matlab

Plotly Graphing Library for MATLAB®
https://plot.ly/matlab/
MIT License
381 stars 167 forks source link

docs - dendogram margin #422

Open danton267 opened 3 years ago

danton267 commented 3 years ago

Would it be possible to remove margin (on the left side of the plot), because it makes the plots in the online docs function badly.

When you open the plot in the browser you can see the dendogram plots are shifted to the right, with big white gap on the left. This causes the plot to be shifted right when embedded, and the plot controls disappear.

link: https://github.com/plotly/plotly.matlab-docs/blob/main/matlab/2021-08-04-dendrogram.md

gilbertogalvis commented 2 years ago

This issue was fixed by PR #469

To fix this I have proposed a new optional parameter called 'DomainFactor'. This parameter scales each of the domain components of the plotly chart.

The domain or position of a chart box is defined by a 4-element vector, namely:

domain = [xo, yo, w, h] where:

Then the 'DomainFactor' parameter must be a vector of 4-elements at most, in which each of its elements will scale to each of the elements of the chart's domain.

Example: Without scaling

rng('default')
X = rand(10,3);

tree = linkage(X,'average');

dendrogram(tree)

fig2plotly(gcf);

In this example we have not set the optional DomainFactor parameter, therefore, the domain of the chart will not be scaled, which will result in:

Screen Shot 2021-11-01 at 4 46 47 PM

Example: set DomianFactor to scaling

rng('default')
X = rand(10,3);

tree = linkage(X,'average');

dendrogram(tree)

domainFactor = [0.2, 1, 0.9, 0.9];
fig2plotly(gcf, 'offline', offline, 'DomainFactor', domainFactor);

In this case we have set the 'DomainFactor' parameter as [0.2, 1, 0.9, 0.9] and like this:

Here I share the result:

Screen Shot 2021-11-01 at 4 47 26 PM