This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sepal_length | sepal_width | petal_length | petal_width | species | |
---|---|---|---|---|---|
5.1 | 3.5 | 1.4 | 0.2 | Iris-setosa | |
4.9 | 3.0 | 1.4 | 0.2 | Iris-setosa | |
4.7 | 3.2 | 1.3 | 0.2 | Iris-setosa | |
4.6 | 3.1 | 1.5 | 0.2 | Iris-setosa | |
5.0 | 3.6 | 1.4 | 0.2 | Iris-setosa | |
5.4 | 3.9 | 1.7 | 0.4 | Iris-setosa | |
4.6 | 3.4 | 1.4 | 0.3 | Iris-setosa | |
5.0 | 3.4 | 1.5 | 0.2 | Iris-setosa | |
4.4 | 2.9 | 1.4 | 0.2 | Iris-setosa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="description" content=""> | |
<title>Iris Scatter Plots</title> | |
<!-- Bootstrap --> | |
<!-- CSS only --> | |
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous"> | |
<!-- JavaScript Bundle with Popper --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// set the dimensions and margins of the graph | |
const margin = {top: 10, right: 30, bottom: 40, left: 70}, | |
width = 800 - margin.left - margin.right, | |
height = 600 - margin.top - margin.bottom; | |
// append the svg object to the body of the page | |
const svg = d3.select("body") | |
.append("svg") | |
.attr("width", width + margin.left + margin.right) | |
.attr("height", height + margin.top + margin.bottom) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// set the dimensions and margins of the graph | |
const margin = {top: 10, right: 30, bottom: 40, left: 70}, | |
width = 800 - margin.left - margin.right, | |
height = 600 - margin.top - margin.bottom; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// append the svg object to the body of the page | |
const svg = d3.select("body") | |
.append("svg") | |
.attr("width", width + margin.left + margin.right) | |
.attr("height", height + margin.top + margin.bottom) | |
.append("g") | |
.attr("transform", `translate(${margin.left},${margin.top})`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d3.csv("data/iris.csv").then( function(data) { | |
console.log(data) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// set the dimensions and margins of the graph | |
const margin = {top: 10, right: 30, bottom: 40, left: 70}, | |
width = 800 - margin.left - margin.right, | |
height = 600 - margin.top - margin.bottom; | |
// append the svg object to the body of the page | |
const svg = d3.select("body") | |
.append("svg") | |
.attr("width", width + margin.left + margin.right) | |
.attr("height", height + margin.top + margin.bottom) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d3.csv("data/iris.csv").then( function(data) { | |
// clean/fix the data | |
data.forEach(function(d) { | |
d.sepal_width = +Number(d.sepal_width); | |
d.sepal_length = +Number(d.sepal_length); | |
d.petal_width = +Number(d.petal_width); | |
d.petal_length = +Number(d.petal_length); | |
}); | |
console.log(data) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add X axis | |
const x = d3.scaleLinear() | |
.domain([1.5, 5]) | |
.range([ 0, width ]); | |
// Add Y axis | |
const y = d3.scaleLinear() | |
.domain([3, 8.5]) | |
.range([ height, 0]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add X axis | |
const x = d3.scaleLinear() | |
.domain([1.5, 5]) | |
.range([ 0, width ]); | |
svg.append("g") | |
.attr("transform", `translate(0, ${height})`) | |
.call(d3.axisBottom(x)); | |
// Add Y axis | |
const y = d3.scaleLinear() |
OlderNewer