Mapbox Maps vs Geo Maps
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.*Mapboxfunction or otherwise contains one or more traces of typescattermapbox,choroplethmapboxordensitymapbox, 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.LineGeoorChart.Choroplethfunction or otherwise contains one or more traces of typescattergeoorchoropleth, 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.
Physical Base 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)
Cultural Base Maps
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)
<summary> Contains mutable global default values. Changing these values will apply the default values to all consecutive Chart generations. </summary>
type DisplayOptions = inherit DynamicObj new: unit -> DisplayOptions static member addAdditionalHeadTags: additionalHeadTags: XmlNode list -> (DisplayOptions -> DisplayOptions) static member addChartDescription: description: XmlNode list -> (DisplayOptions -> DisplayOptions) static member combine: first: DisplayOptions -> second: DisplayOptions -> DisplayOptions static member getAdditionalHeadTags: displayOpts: DisplayOptions -> XmlNode list static member getChartDescription: displayOpts: DisplayOptions -> XmlNode list static member getDocumentCharset: displayOpts: DisplayOptions -> string static member getDocumentDescription: displayOpts: DisplayOptions -> string static member getDocumentFavicon: displayOpts: DisplayOptions -> XmlNode ...
--------------------
new: unit -> Plotly.NET.DisplayOptions
<summary> Sets how plotly is referenced in the head of html docs. </summary>
static member Chart.PointGeo: lonlat: (#System.IConvertible * #System.IConvertible) seq * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?MultiOpacity: float seq * ?Text: 'c * ?MultiText: 'c seq * ?TextPosition: StyleParam.TextPosition * ?MultiTextPosition: StyleParam.TextPosition seq * ?MarkerColor: Color * ?MarkerColorScale: StyleParam.Colorscale * ?MarkerOutline: Line * ?MarkerSymbol: StyleParam.MarkerSymbol * ?MultiMarkerSymbol: StyleParam.MarkerSymbol seq * ?Marker: TraceObjects.Marker * ?LocationMode: StyleParam.LocationFormat * ?GeoJson: obj * ?FeatureIdKey: string * ?UseDefaults: bool -> GenericChart (requires 'c :> System.IConvertible)
static member Chart.PointGeo: longitudesEncoded: EncodedTypedArray * latitudesEncoded: EncodedTypedArray * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?MultiOpacity: float seq * ?Text: 'a * ?MultiText: 'a seq * ?TextPosition: StyleParam.TextPosition * ?MultiTextPosition: StyleParam.TextPosition seq * ?MarkerColor: Color * ?MarkerColorScale: StyleParam.Colorscale * ?MarkerOutline: Line * ?MarkerSymbol: StyleParam.MarkerSymbol * ?MultiMarkerSymbol: StyleParam.MarkerSymbol seq * ?Marker: TraceObjects.Marker * ?LocationMode: StyleParam.LocationFormat * ?GeoJson: obj * ?FeatureIdKey: string * ?UseDefaults: bool -> GenericChart (requires 'a :> System.IConvertible)
static member Chart.PointGeo: longitudes: #System.IConvertible seq * latitudes: #System.IConvertible seq * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?MultiOpacity: float seq * ?Text: 'c * ?MultiText: 'c seq * ?TextPosition: StyleParam.TextPosition * ?MultiTextPosition: StyleParam.TextPosition seq * ?MarkerColor: Color * ?MarkerColorScale: StyleParam.Colorscale * ?MarkerOutline: Line * ?MarkerSymbol: StyleParam.MarkerSymbol * ?MultiMarkerSymbol: StyleParam.MarkerSymbol seq * ?Marker: TraceObjects.Marker * ?LocationMode: StyleParam.LocationFormat * ?GeoJson: obj * ?FeatureIdKey: string * ?UseDefaults: bool -> GenericChart (requires 'c :> System.IConvertible)
<summary> The central type that gets created by all Chart constructors is GenericChart, which itself represents either a single chart or a multi chart (as a Discriminate Union type). A GenericChart consists of four top level objects: Trace (multiple of those in the case of a MultiChart), Layout, Config, and DisplayOptions. - `Trace` is in principle the representation of a dataset on a chart, including for example the data itself, color and shape of the visualization, etc. - `Layout` is everything of the chart that is not dataset specific - e.g. the shape and style of axes, the chart title, etc. - `Config` is an object that configures high level properties of the chart like making all chart elements editable or the tool bar on top - `DisplayOptions` is an object that contains meta information about how the html document that contains the chart. </summary>
type Geo = inherit DynamicObj new: unit -> Geo static member init: ?FitBounds: GeoFitBounds * ?Resolution: GeoResolution * ?Scope: GeoScope * ?Projection: GeoProjection * ?Center: (float * float) * ?Visible: bool * ?Domain: Domain * ?ShowCoastLines: bool * ?CoastLineColor: Color * ?CoastLineWidth: float * ?ShowLand: bool * ?LandColor: Color * ?ShowOcean: bool * ?OceanColor: Color * ?ShowLakes: bool * ?LakeColor: Color * ?ShowRivers: bool * ?RiverColor: Color * ?RiverWidth: float * ?ShowCountries: bool * ?CountryColor: Color * ?CountryWidth: float * ?ShowSubunits: bool * ?SubunitColor: Color * ?SubunitWidth: float * ?ShowFrame: bool * ?FrameColor: Color * ?FrameWidth: float * ?BgColor: Color * ?LatAxis: LinearAxis * ?LonAxis: LinearAxis -> Geo static member style: ?FitBounds: GeoFitBounds * ?Resolution: GeoResolution * ?Scope: GeoScope * ?Projection: GeoProjection * ?Center: (float * float) * ?Visible: bool * ?Domain: Domain * ?ShowCoastLines: bool * ?CoastLineColor: Color * ?CoastLineWidth: float * ?ShowLand: bool * ?LandColor: Color * ?ShowOcean: bool * ?OceanColor: Color * ?ShowLakes: bool * ?LakeColor: Color * ?ShowRivers: bool * ?RiverColor: Color * ?RiverWidth: float * ?ShowCountries: bool * ?CountryColor: Color * ?CountryWidth: float * ?ShowSubunits: bool * ?SubunitColor: Color * ?SubunitWidth: float * ?ShowFrame: bool * ?FrameColor: Color * ?FrameWidth: float * ?BgColor: Color * ?LatAxis: LinearAxis * ?LonAxis: LinearAxis -> (Geo -> Geo)
<summary>Determines the style of the map shown in geo traces</summary>
--------------------
new: unit -> Geo
<summary> Used for the Layout.geo field. Sets the resolution of the base layers. The values have units of km/mm e.g. 110 corresponds to a scale ratio of 1:110,000,000. </summary>
<summary> Plotly color can be a single color, a sequence of colors, or a sequence of numeric values referencing the color of the colorscale obj </summary>
Plotly.NET