Wykresy liniowe

  • Liniowy
  • Nachylenie
  • Przechwycić

Liniowy

Liniowy oznacza prosty. Wykres liniowy to linia prosta.

Ogólnie rzecz biorąc, wykres liniowy wyświetla wartości funkcji.

Przykład

var xValues = [];
var yValues = [];

// Generate values
for (var x = 0; x <= 10; x += 1) {
  xValues.push(x);
  yValues.push(x);
}

// Display using Plotly
var data = [{
  x: xValues,
  y: yValues,
  mode: "lines"
}];

// Define Layout
var layout = {title: "y = x"};
// Display using Plotly
Plotly.newPlot("myPlot", data, layout);

Nachylenie

Nachylenie to kąt wykresu.

Nachylenie to wartość na wykresie liniowym:

y = x

W tym przykładzie nachylenie = 1,2 :

Przykład

var slope = 1.2;
var xValues = [];
var yValues = [];

// Generate values
for (var x = 0; x <= 10; x += 1) {
  xValues.push(x);
  yValues.push(x * slope);
}

// Define Data
var data = [{
  x: xValues,
  y: yValues,
  mode: "lines"
}];
// Define Layout
var layout = {title: "Slope=" + slope};

// Display using Plotly
Plotly.newPlot("myPlot", data, layout);

Przechwycić

Punkt przecięcia to wartość początkowa wykresu.

Punkt przecięcia to wartość b na wykresie liniowym:

y = topór + b

W tym przykładzie nachylenie = 1,2 i przecięcie = 2 :

Przykład

var slope = 1.2;
var intercept = 7;
var xValues = [];
var yValues = [];

// Generate values
for (var x = 0; x <= 10; x += 1) {
  xValues.push(x);
  yValues.push(x * slope + intercept);
}

// Define Data
var data = [{
  x: xValues,
  y: yValues,
  mode: "lines"
}];

// Define Layout
var layout = {title: "Slope=" + slope + " Intercept=" + intercept};

// Display using Plotly
Plotly.newPlot("myPlot", data, layout);