Git Product home page Git Product logo

Comments (1)

gilbertogalvis avatar gilbertogalvis commented on June 6, 2024

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

Screen Shot 2021-10-23 at 12 32 43 PM

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);

Screen Shot 2021-10-23 at 12 39 58 PM

from plotly_matlab.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.