Gráficos lineares

  • Linear
  • Declive
  • Interceptar

Linear

Linear significa reto. Um gráfico linear é uma linha reta.

Em geral, um gráfico linear exibe os valores da função.

Exemplo

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

Declive

A inclinação é o ângulo do gráfico.

A inclinação é o valor a em um gráfico linear:

y = ax

Neste exemplo, inclinação = 1,2 :

Exemplo

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

Interceptar

O Intercept é o valor inicial do gráfico.

A interceptação é o valor b em um gráfico linear:

y = ax + b

Neste exemplo, inclinação = 1,2 e interceptação = 2 :

Exemplo

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