diff --git a/fsharp/filled-area-on-mapbox.md b/fsharp/filled-area-on-mapbox.md index c87fefd..053b70f 100644 --- a/fsharp/filled-area-on-mapbox.md +++ b/fsharp/filled-area-on-mapbox.md @@ -38,7 +38,7 @@ jupyter: ``` # Mapbox Access Token and Base Map Configuration -To plot on Mapbox maps with Plotly you may need a Mapbox account and a public Mapbox Access Token. +To plot on Mapbox maps with Plotly you may need a Mapbox account and a public Mapbox Access Token. There are three different ways to show a filled area in a Mapbox map: diff --git a/fsharp/lines-on-mapbox.md b/fsharp/lines-on-mapbox.md index 02f0e73..547f90c 100644 --- a/fsharp/lines-on-mapbox.md +++ b/fsharp/lines-on-mapbox.md @@ -39,7 +39,7 @@ jupyter: ``` # Mapbox Access Token and Base Map Configuration -To plot on Mapbox maps with Plotly you may need a Mapbox account and a public Mapbox Access Token. +To plot on Mapbox maps with Plotly you may need a Mapbox account and a public Mapbox Access Token. # Lines on Mapbox maps @@ -52,7 +52,7 @@ open Plotly.NET.LayoutObjects let data = CsvFile.Load("https://raw.githubusercontent.com/plotly/datasets/master/us-cities-top-1k.csv") -let getData state = data.Rows +let getData state = data.Rows |> Seq.filter (fun row -> row.GetColumn("State") = state) |> Seq.map (fun row -> row.GetColumn("lon"),row.GetColumn("lat")) @@ -74,9 +74,9 @@ let ohioData = getData "Ohio" This example uses Chart.ScatterMapbox and sets the mode attribute to a combination of markers and line. ```fsharp dotnet_interactive={"language": "fsharp"} -[ +[ Chart.ScatterMapbox(longitudes = [ 10; 20; 30 ], latitudes = [ 10; 20; 30 ], mode = StyleParam.Mode.Lines_Markers) - Chart.ScatterMapbox(longitudes = [ -50; -60; 40 ], latitudes = [ 30; 10; -20 ], mode = StyleParam.Mode.Lines_Markers) + Chart.ScatterMapbox(longitudes = [ -50; -60; 40 ], latitudes = [ 30; 10; -20 ], mode = StyleParam.Mode.Lines_Markers) ] |> Chart.combine diff --git a/fsharp/mapbox-county-choropleth.md b/fsharp/mapbox-county-choropleth.md index e3c27a5..cb8ccfa 100644 --- a/fsharp/mapbox-county-choropleth.md +++ b/fsharp/mapbox-county-choropleth.md @@ -42,7 +42,7 @@ jupyter: A Choropleth Map is a map composed of colored polygons. It is used to represent spatial variations of a quantity. This page documents how to build tile-map choropleth maps, but you can also build outline choropleth maps using our non-Mapbox trace types. # Mapbox Access Tokens and Base Map Configuration -To plot on Mapbox maps with Plotly you may need a Mapbox account and a public Mapbox Access Token +To plot on Mapbox maps with Plotly you may need a Mapbox account and a public Mapbox Access Token # Introduction: main parameters for choropleth tile maps @@ -79,7 +79,7 @@ Here we load unemployment data by county, also indexed by FIPS code. open Deedle open FSharp.Data -let data = +let data = Http.RequestString "https://raw.githubusercontent.com/plotly/datasets/master/fips-unemp-16.csv" |> fun csv -> Frame.ReadCsvString(csv,true,separators=",",schema="fips=string,unemp=float") @@ -107,21 +107,21 @@ open FSharp.Data open Deedle open Plotly.NET.LayoutObjects -let data = +let data = Http.RequestString "https://raw.githubusercontent.com/plotly/datasets/master/fips-unemp-16.csv" |> fun csv -> Frame.ReadCsvString(csv,true,separators=",",schema="fips=string,unemp=float") - -let geoJson = + +let geoJson = Http.RequestString "https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json" - |> JsonConvert.DeserializeObject - -let locations: string [] = + |> JsonConvert.DeserializeObject + +let locations: string [] = data |> Frame.getCol "fips" |> Series.values |> Array.ofSeq -let z: int [] = +let z: int [] = data |> Frame.getCol "unemp" |> Series.values @@ -129,7 +129,7 @@ let z: int [] = Chart.ChoroplethMapbox(z=z,geoJson=geoJson,locations=locations,FeatureIdKey="id",Colorscale=StyleParam.Colorscale.Viridis,ZMin=0.,ZMax=12.) |> Chart.withMapbox( - Mapbox.init(Style=StyleParam.MapboxStyle.CartoPositron,Zoom=3.,Center=(-95.7129,37.0902)) + Mapbox.init(Style=StyleParam.MapboxStyle.CartoPositron,Zoom=3.,Center=(-95.7129,37.0902)) ) ``` @@ -146,21 +146,21 @@ open FSharp.Data open Deedle open Newtonsoft.Json -let data = +let data = Http.RequestString "https://raw.githubusercontent.com/plotly/datasets/master/election.csv" |> fun csv -> Frame.ReadCsvString(csv,true,separators=",") -let geoJson = +let geoJson = Http.RequestString "https://raw.githubusercontent.com/plotly/datasets/master/election.geojson" - |> JsonConvert.DeserializeObject + |> JsonConvert.DeserializeObject -let locationsGeoJSON: string [] = +let locationsGeoJSON: string [] = data |> Frame.getCol "district" |> Series.values |> Array.ofSeq -let zGeoJSON: int [] = +let zGeoJSON: int [] = data |> Frame.getCol "Bergeron" |> Series.values @@ -168,13 +168,13 @@ let zGeoJSON: int [] = Chart.ChoroplethMapbox( locations = locationsGeoJSON, - z = zGeoJSON, + z = zGeoJSON, geoJson = geoJson, Colorscale= StyleParam.Colorscale.Cividis, FeatureIdKey="properties.district") - + |> Chart.withMapbox( - Mapbox.init(Style=StyleParam.MapboxStyle.CartoPositron,Zoom=9.,Center=(-73.7073,45.5517)) + Mapbox.init(Style=StyleParam.MapboxStyle.CartoPositron,Zoom=9.,Center=(-73.7073,45.5517)) ) |> Chart.withColorBarStyle(Title.init(Text="Bergeron Votes")) |> Chart.withTitle(title="2013 Montreal Election") @@ -189,17 +189,17 @@ open Newtonsoft.Json let token = "pk.eyJ1IjoibWFoZXNocHVubmEiLCJhIjoiY2t0NXB4eXA0MGFzYjJxcXN3b2xpNzc2ZSJ9.xliv67HWVdNd_tfmfgMXmA" //# you will need your own token -let data = +let data = Http.RequestString "https://raw.githubusercontent.com/plotly/datasets/master/fips-unemp-16.csv" |> fun csv -> Frame.ReadCsvString(csv,true,separators=",",schema="fips=string,unemp=float") -let locations: string [] = +let locations: string [] = data |> Frame.getCol "fips" |> Series.values |> Array.ofSeq -let z: int [] = +let z: int [] = data |> Frame.getCol "unemp" |> Series.values @@ -207,7 +207,7 @@ let z: int [] = Chart.ChoroplethMapbox(z=z,geoJson=geoJson,locations=locations,FeatureIdKey="id",Colorscale=StyleParam.Colorscale.Viridis,ZMin=0.,ZMax=12.) |> Chart.withMapbox( - Mapbox.init(Style=StyleParam.MapboxStyle.MapboxLight,Zoom=3.,Center=(-95.7129,37.0902),AccessToken=token) + Mapbox.init(Style=StyleParam.MapboxStyle.MapboxLight,Zoom=3.,Center=(-95.7129,37.0902),AccessToken=token) ) ``` diff --git a/fsharp/mapbox-density-heatmaps.md b/fsharp/mapbox-density-heatmaps.md index d1b41ae..d674eca 100644 --- a/fsharp/mapbox-density-heatmaps.md +++ b/fsharp/mapbox-density-heatmaps.md @@ -39,7 +39,7 @@ jupyter: ``` # Mapbox Access Token and Base Map Configuration -To plot on Mapbox maps with Plotly you may need a Mapbox account and a public Mapbox Access Token. +To plot on Mapbox maps with Plotly you may need a Mapbox account and a public Mapbox Access Token. # Stamen Terrain base map (no token needed): density mapbox with Plotly.NET