#r "nuget: Plotly.NET, 2.0.0"
#r "nuget: Plotly.NET.Interactive, 2.0.0"
Summary: This example shows how to create DensityMapbox charts in F#.
Chart.DensityMapbox
draws a bivariate kernel density estimation with a Gaussian kernel from lon
and lat
coordinates and optional z
values using a colorscale.
This Chart uses Mapbox layers and might need a Mapbox API token depending on the desired base map layer style.
// we are using the awesome FSharp.Data project here to perform a http request,
// and the awesome Deedle library to read the data as a data frame
#r "nuget: FSharp.Data"
#r "nuget: Deedle"
open FSharp.Data
open Deedle
let dataDensityMapbox =
Http.RequestString "https://raw.githubusercontent.com/plotly/datasets/master/earthquakes-23k.csv"
|> fun d -> Frame.ReadCsvString(d,true,separators=",")
let lon = dataDensityMapbox.["Longitude"] |> Series.values
let lat= dataDensityMapbox.["Latitude"] |> Series.values
let magnitudes = dataDensityMapbox.["Magnitude"] |> Series.values
open Plotly.NET
open Plotly.NET.LayoutObjects
let densityMapbox =
Chart.DensityMapbox(
lon,
lat,
Z = magnitudes,
Radius=8,
ColorScale=StyleParam.Colorscale.Viridis
)
|> Chart.withMapbox(
Mapbox.init(
Style = StyleParam.MapboxStyle.StamenTerrain,
Center = (60.,30.)
)
)
densityMapbox