d3.js for scatter plot with lineathena.ecs.csus.edu/~natesha/project_source_code.pdf · d3.js for...

Post on 22-Aug-2020

14 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

D3.js for scatter plot with line

var w = 200;

var h = 200;

//create the svg element and set the height and width parameters

var svg = d3.select("div").select("div")

.append("svg")

.attr("height",h)

.attr("width", w)

.style("border", "1px solid black");

if(dataSource == 0){

d3.json("covtype.csv", function(error, root) {

console.log(root);

if (error) throw error;

//Create the scale for the scatter plot

var xScale = d3.scale.linear()

.domain([d3.min(dataset, function(d) { return d[0];}),d3.max(dataset, function(d) { return d[0];})])

.range([-1,1]);

var yScale = d3.scale.linear()

.domain([d3.min(dataset, function(d) { return d[1];}),d3.max(dataset, function(d) { return d[1];})])

.range([-1,1]);

//This is the function that creates the SVG lines

var line = svg.selectAll("line")

.data(lisa)

.enter()

.append("line");

//This gets the cooresponding x,y cordinates from the dataset

line.attr("x1", function(d) {

return xScale(d[0]);

})

.attr("y1", function(d) {

return yScale(d[1]);

})

.attr("x2", function(d) {

return xScale(d[2]);

})

.attr("y2", function(d) {

return yScale(d[3]);

})

.attr("stroke", "black");

PCA in Python -Jupyter NoteBook

Feature Extraction, Model building and performance evaluation

top related