You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
load accidents
x = hwydata(:,14); %Population of states
y = hwydata(:,4); %Accidents per state
X = [ones(length(x),1) x];
b = X\y;
yCalc2 = X*b;
plot(x,yCalc2,'--');
legend('Data','Slope','Slope & Intercept','Location','best');
fig2plotly(gcf);
yields following error
Warning: Ignoring extra legend entries.
> In legend>process_inputs (line 587)
In legend>make_legend (line 315)
In legend (line 259)
In temp (line 10)
The text was updated successfully, but these errors were encountered:
That error you report is caused by MATLAB but not by matlab_plotly. This is because you are not using the MATLAB legend function correctly. You are passing the parameters wrong when you invoke legend.
Since you have a single plot line, you can only pass one label in legend, which would be 'Data' or 'Slope' or 'Slope & Intersection'. But you can't go through three because the chart doesn't have three traces.
The correct use would be the following
load accidents
x = hwydata(:,14) %Population of states
y = hwydata(:,4) %Accidents per state
X = [ones(length(x),1) x];
b = X\y;
yCalc2 = X*b
plot(x,yCalc2,'--');
legend({'Data'},'Location','best');
fig2plotly(gcf);
result will be
Data+Slope
If you want to plot both the data and the slope, you need to do the following
load accidents
x = hwydata(:,14) %Population of states
y = hwydata(:,4) %Accidents per state
X = [ones(length(x),1) x];
b = X\y;
yCalc2 = X*b
plot(x,y,'o');
hold on
plot(x,yCalc2,'--');
legend({'Data', 'Slope'},'Location','best');
fig2plotly(gcf);
yields following error
The text was updated successfully, but these errors were encountered: