Public
Edited
Nov 16, 2023
Insert cell
Insert cell
output_2.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
all_data = FileAttachment("output_2.csv").csv()
Insert cell
Plotly = require("https://cdn.plot.ly/plotly-latest.min.js")
Insert cell
all_data_2 = all_data.withColumn('date', row => new Date(row.get('date')));
Insert cell
high_tide = {
const high_tide = all_data.filter(obj => obj.highlow == "H")
return high_tide
}
Insert cell
low_tide = {
const low_tide = all_data.filter(obj => obj.highlow == "L")
return low_tide
}
Insert cell
{
let data = [{
x: high_tide.map(item => item.date),
y: high_tide.map(item => item.pred_in_cm),
mode: "lines+markers"
}]

let layout = { // there are many layout options, in this example we just set the dimensions
title: {
text:'Plot Title',
font: {
family: 'Courier New, monospace',
size: 24
},
xref: 'paper',
x: 0.05,
},
xaxis: {
title: {
text: 'x Axis',
font: {
family: 'Courier New, monospace',
size: 18,
color: '#7f7f7f'
}
},
},
yaxis: {
title: {
text: 'y Axis',
font: {
family: 'Courier New, monospace',
size: 18,
color: '#7f7f7f'
}
}
},
height: 400,
width: 900
};
const div = DOM.element('div');
Plotly.newPlot(div, data, layout);
return div;
}
Insert cell
{
let data = [{
x: low_tide.map(item => item.date),
y: low_tide.map(item => item.pred_in_cm),
mode: "lines+markers"
}]

let layout = { // there are many layout options, in this example we just set the dimensions
title: {
text:'Plot Title',
font: {
family: 'Courier New, monospace',
size: 24
},
xref: 'paper',
x: 0.05,
},
xaxis: {
title: {
text: 'x Axis',
font: {
family: 'Courier New, monospace',
size: 18,
color: '#7f7f7f'
}
},
},
yaxis: {
title: {
text: 'y Axis',
font: {
family: 'Courier New, monospace',
size: 18,
color: '#7f7f7f'
}
}
},
height: 400,
width: 900
};
const div = DOM.element('div');
Plotly.newPlot(div, data, layout);
return div;
}
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