Skip to content

Commit 34ef100

Browse files
rounding out mapbox functions
1 parent d2cec8f commit 34ef100

File tree

3 files changed

+37
-33
lines changed

3 files changed

+37
-33
lines changed

packages/python/plotly/plotly/express/_chart_types.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,8 @@ def scatter_mapbox(
981981
opacity=None,
982982
size_max=None,
983983
zoom=8,
984+
center=None,
985+
mapbox_style=None,
984986
title=None,
985987
template=None,
986988
width=None,
@@ -1012,7 +1014,9 @@ def choropleth_mapbox(
10121014
range_color=None,
10131015
color_continuous_midpoint=None,
10141016
opacity=None,
1015-
zoom=None,
1017+
zoom=8,
1018+
center=None,
1019+
mapbox_style=None,
10161020
title=None,
10171021
template=None,
10181022
width=None,
@@ -1049,6 +1053,8 @@ def density_mapbox(
10491053
color_continuous_midpoint=None,
10501054
opacity=None,
10511055
zoom=8,
1056+
center=None,
1057+
mapbox_style=None,
10521058
radius=None,
10531059
title=None,
10541060
template=None,

packages/python/plotly/plotly/express/_core.py

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -504,13 +504,11 @@ def configure_cartesian_axes(args, fig, orders):
504504

505505

506506
def configure_ternary_axes(args, fig, orders):
507-
fig.update(
508-
layout=dict(
509-
ternary=dict(
510-
aaxis=dict(title=get_label(args, args["a"])),
511-
baxis=dict(title=get_label(args, args["b"])),
512-
caxis=dict(title=get_label(args, args["c"])),
513-
)
507+
fig.update_layout(
508+
ternary=dict(
509+
aaxis=dict(title=get_label(args, args["a"])),
510+
baxis=dict(title=get_label(args, args["b"])),
511+
caxis=dict(title=get_label(args, args["c"])),
514512
)
515513
)
516514

@@ -564,30 +562,28 @@ def configure_3d_axes(args, fig, orders):
564562

565563

566564
def configure_mapbox(args, fig, orders):
567-
fig.update(
568-
layout=dict(
569-
mapbox=dict(
570-
accesstoken=MAPBOX_TOKEN,
571-
center=dict(
572-
lat=args["data_frame"][args["lat"]].mean(),
573-
lon=args["data_frame"][args["lon"]].mean(),
574-
)
575-
if "lat" in args and "lon" in args
576-
else dict(),
577-
zoom=args["zoom"],
578-
)
565+
center = args["center"]
566+
if not center and "lat" in args and "lon" in args:
567+
center = dict(
568+
lat=args["data_frame"][args["lat"]].mean(),
569+
lon=args["data_frame"][args["lon"]].mean(),
570+
)
571+
fig.update_layout(
572+
mapbox=dict(
573+
accesstoken=MAPBOX_TOKEN,
574+
center=center,
575+
zoom=args["zoom"],
576+
style=args["mapbox_style"],
579577
)
580578
)
581579

582580

583581
def configure_geo(args, fig, orders):
584-
fig.update(
585-
layout=dict(
586-
geo=dict(
587-
center=args["center"],
588-
scope=args["scope"],
589-
projection=dict(type=args["projection"]),
590-
)
582+
fig.update_layout(
583+
geo=dict(
584+
center=args["center"],
585+
scope=args["scope"],
586+
projection=dict(type=args["projection"]),
591587
)
592588
)
593589

@@ -1013,7 +1009,7 @@ def infer_config(args, constructor, trace_patch):
10131009
attrables = (
10141010
["x", "y", "z", "a", "b", "c", "r", "theta", "size", "dimensions"]
10151011
+ ["custom_data", "hover_name", "hover_data", "text"]
1016-
+ ["names", "values", "parents", "ids", "radius"]
1012+
+ ["names", "values", "parents", "ids"]
10171013
+ ["error_x", "error_x_minus"]
10181014
+ ["error_y", "error_y_minus", "error_z", "error_z_minus"]
10191015
+ ["lat", "lon", "locations", "animation_group"]

packages/python/plotly/plotly/express/_doc.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,7 @@
164164
colref_desc,
165165
"Values from this column or array_like are used to assign mark sizes.",
166166
],
167-
radius=[
168-
colref_type,
169-
colref_desc,
170-
"Values from this column or array_like are used to set the radius of influence of each point.",
171-
],
167+
radius=["int (default is 30)", "Sets the radius of influence of each point.",],
172168
hover_name=[
173169
colref_type,
174170
colref_desc,
@@ -450,6 +446,12 @@
450446
"Dict keys are `'lat'` and `'lon'`",
451447
"Sets the center point of the map.",
452448
],
449+
mapbox_style=[
450+
"str (default `'basic'`, needs Mapbox API token)",
451+
"Identifier of base map style, some of which require a Mapbox API token to be set using `plotly.express.set_mapbox_access_token()`.",
452+
"Allowed values which do not require a Mapbox API token are `'open-street-map'`, `'white-bg'`, `'carto-positron'`, `'carto-darkmatter'`, `'stamen-terrain'`, `'stamen-toner'`, `'stamen-watercolor'`.",
453+
"Allowed values which do require a Mapbox API token are `'basic'`, `'streets'`, `'outdoors'`, `'light'`, `'dark'`, `'satellite'`, `'satellite-streets'`.",
454+
],
453455
points=[
454456
"str or boolean (default `'outliers'`)",
455457
"One of `'outliers'`, `'suspectedoutliers'`, `'all'`, or `False`.",

0 commit comments

Comments
 (0)