Published
Edited
Feb 21, 2019
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// used this do double check that my quake data was coming in exampleQuakeData = quakes.features[0].properties
Insert cell
Insert cell
//to pull out the earquakes from data
all = {
var features = quakes.features;
return features.map(function(d) {return d.properties; }); //putting the [0] regturns just the first coordinate for all the earthquakes. So you could get just the longitude this way.

}
Insert cell
{
// identify x (time) and y (magnitute) coordinates as being properties of earthquake geojson. putting all attributes in the variable plot1
var plot1 = {
x: all.map(function(d) {return d.mag; }),
y: all.map(function(d) {return d.time; }),
mode: 'markers',
type: 'scatter',
marker: { size: 12 }
};
// Layout uses Plot.ly's default aspect ratio, with Observable's "width"
var layout = {
title: 'Earthquakes Over Time',
height: 450 * width / 700
};

// Plotly's data model for scatterplots
var data = [plot1];
// The call to Plotly.js, using the string "myDiv", which puts the graph in: "<div id='myDiv'></div>
Plotly.newPlot('myDiv', data, layout);
// Return the values so we can see the data Array
return plot1;
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more