Skip to content

Conversation

gilbertogalvis
Copy link
Contributor

This PR fix the issues posted in issue #436

Example 1

load carsmall
tbl = table(Horsepower,MPG,Cylinders);
s = scatterhistogram(tbl,'Horsepower','MPG', ...
		  'GroupVariable','Cylinders','HistogramDisplayStyle','smooth', ...
		  'LineStyle','-');

fig2plotly(gcf);

Screen Shot 2021-10-29 at 8 45 17 PM

Example 2

x0 = randn(100,1)./5. + 0.5;
y0 = randn(100,1)./5. + 0.5;
x1 = rand(50,1);
y1 = rand(50,1) + 1.0;

x = [x0; x1];
y = [y0; y1];

trace1 = struct(...
  'x', x0, ...
  'y', y0, ...
  'mode', 'markers', ...
  'marker', struct(...
    'symbol', 'circle', ...
    'opacity', 0.7), ...
  'type', 'scatter');

trace2 = struct(...
  'x', x1, ...
  'y', y1, ...
  'mode', 'markers', ...
  'marker', struct(...
    'symbol', 'square', ...
    'opacity', 0.7), ...
  'type', 'scatter');

trace3 = struct(...
  'x', x, ...
  'y', y, ...
  'type', 'histogram2d');

data = {trace1, trace2, trace3};

plotly(data);

This particular issue is because you are not setting the layout for the legend (you are leaving it by default). Then plotly position the legend wherever (in this case under the colorbar)

To fix it, you only have to configure the legend in the layout struct, in such a way that you correctly specify its position (avoiding that it is below the colorbar).

For this, please use the following code

x0 = randn(100,1)./5. + 0.5;
y0 = randn(100,1)./5. + 0.5;
x1 = rand(50,1);
y1 = rand(50,1) + 1.0;

x = [x0; x1];
y = [y0; y1];

trace1 = struct(...
		'x', x0, ...
		'y', y0, ...
		'mode', 'markers', ...
		'marker', struct(...
		  'symbol', 'circle', ...
		  'opacity', 0.7), ...
		'type', 'scatter');

trace2 = struct(...
		'x', x1, ...
		'y', y1, ...
		'mode', 'markers', ...
		'marker', struct(...
		  'symbol', 'square', ...
		  'opacity', 0.7), ...
		'type', 'scatter');

trace3 = struct(...
		'x', x, ...
		'y', y, ...
		'type', 'histogram2d');

data = {trace1, trace2, trace3};

layout = struct(...
		  'legend', struct(...
		'y', 1.0, ...
		'yanchor', 'bottom', ...
		'x', 1.0, ...
		'xanchor', 'right'), ...
		  'xaxis', struct('zeroline', false), ...
		  'yaxis', struct('zeroline', false) ...
		  );

plotly(data, struct('layout', layout));

Screen Shot 2021-10-29 at 8 45 37 PM

Example 3

x = 2*randn(1000,1)+2;
y = 5*randn(1000,1)+3;
h = histogram2(x,y,'DisplayStyle','tile','ShowEmptyBins','on');

fig2plotly(gcf);

Screen Shot 2021-10-29 at 8 45 58 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