Summary: This introduction shows the differences between Geo and Mapbox based geographical charts.
Plotly and therefore Plotly.NET supports two different kinds of maps:
Mapbox maps are tile-based maps. If your figure is created with a Chart.*Mapbox
function or otherwise contains one or more traces of type scattermapbox
,
choroplethmapbox
or densitymapbox
, the layout.mapbox object in your figure contains configuration information for the map itself.
Geo maps are outline-based maps. If your figure is created with a Chart.ScatterGeo
, Chart.PointGeo
, Chart.LineGeo
or Chart.Choropleth
function or
otherwise contains one or more traces of type scattergeo
or choropleth
, the layout.geo object in your figure contains configuration information for the map itself.
This page documents Geo outline-based maps, and the Mapbox Layers documentation describes how to configure Mapbox tile-based maps.
Plotly Geo maps have a built-in base map layer composed of "physical" and "cultural" (i.e. administrative border) data from the Natural Earth Dataset. Various lines and area fills can be shown or hidden, and their color and line-widths specified. In the default plotly template, a map frame and physical features such as a coastal outline and filled land areas are shown, at a small-scale 1:110m resolution:
open Plotly.NET
let baseMapOnly =
Chart.PointGeo(locations = []) // deliberately empty chart to show the base map only
|> Chart.withMarginSize (0, 0, 0, 0)
To control the features of the map, a Geo
object is used that can be associated with a given chart using the Chart.WithGeo
function.
Here is a map with all physical features enabled and styled, at a larger-scale 1:50m resolution:
open Plotly.NET.LayoutObjects
let myGeo =
Geo.init (
Resolution = StyleParam.GeoResolution.R50,
ShowCoastLines = true,
CoastLineColor = Color.fromString "RebeccaPurple",
ShowLand = true,
LandColor = Color.fromString "LightGreen",
ShowOcean = true,
OceanColor = Color.fromString "LightBlue",
ShowLakes = true,
LakeColor = Color.fromString "Blue",
ShowRivers = true,
RiverColor = Color.fromString "Blue"
)
let moreFeaturesBaseMap =
Chart.PointGeo(locations = [])
|> Chart.withGeo myGeo
|> Chart.withMarginSize (0, 0, 0, 0)
In addition to physical base map features, a "cultural" base map is included which is composed of country borders and selected sub-country borders such as states.
Note and disclaimer: cultural features are by definition subject to change, debate and dispute. Plotly includes data from Natural Earth "as-is" and defers to the Natural Earth policy regarding disputed borders which read:
Natural Earth Vector draws boundaries of countries according to defacto status. We show who actually controls the situation on the ground.
Here is a map with only cultural features enabled and styled, at a 1:50m resolution, which includes only country boundaries. See below for country sub-unit cultural base map features:
let countryGeo =
Geo.init (
Visible = false,
Resolution = StyleParam.GeoResolution.R50,
ShowCountries = true,
CountryColor = Color.fromString "RebeccaPurple"
)
let countryBaseMap =
Chart.PointGeo(locations = [])
|> Chart.withGeo countryGeo
|> Chart.withMarginSize (0, 0, 0, 0)