Grafik Linier
- Linier
- Lereng
- Mencegat
Linier
Linier berarti lurus. Graf linier adalah sebuah garis lurus.
Secara umum, grafik linier menampilkan nilai-nilai fungsi.
Contoh
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);
Lereng
Kemiringan adalah sudut grafik.
Kemiringan adalah nilai dalam grafik linier:
y = a x
Dalam contoh ini, kemiringan = 1,2 :
Contoh
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);
Mencegat
Intercept adalah nilai awal dari grafik.
Intersep adalah nilai b dalam grafik linier:
y = kapak + b
Dalam contoh ini, kemiringan = 1,2 dan intersep = 2 :
Contoh
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);