Skip to content

Commit cd2d4ad

Browse files
committed
Renamed create_hexbin_mapbox to create_hexbin_map
1 parent 565a92c commit cd2d4ad

File tree

5 files changed

+40
-26
lines changed

5 files changed

+40
-26
lines changed

doc/apidoc/plotly.figure_factory.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
create_distplot
1919
create_facet_grid
2020
create_gantt
21-
create_hexbin_mapbox
21+
create_hexbin_map
2222
create_ohlc
2323
create_quiver
2424
create_scatterplotmatrix

doc/python/hexbin-mapbox.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import plotly.express as px
4646
px.set_mapbox_access_token(open(".mapbox_token").read())
4747
df = px.data.carshare()
4848

49-
fig = ff.create_hexbin_mapbox(
49+
fig = ff.create_hexbin_map(
5050
data_frame=df, lat="centroid_lat", lon="centroid_lon",
5151
nx_hexagon=10, opacity=0.9, labels={"color": "Point Count"},
5252
)
@@ -63,7 +63,7 @@ import plotly.express as px
6363
px.set_mapbox_access_token(open(".mapbox_token").read())
6464
df = px.data.carshare()
6565

66-
fig = ff.create_hexbin_mapbox(
66+
fig = ff.create_hexbin_map(
6767
data_frame=df, lat="centroid_lat", lon="centroid_lon",
6868
nx_hexagon=10, opacity=0.5, labels={"color": "Point Count"},
6969
min_count=1,
@@ -80,7 +80,7 @@ import plotly.express as px
8080
px.set_mapbox_access_token(open(".mapbox_token").read())
8181
df = px.data.carshare()
8282

83-
fig = ff.create_hexbin_mapbox(
83+
fig = ff.create_hexbin_map(
8484
data_frame=df, lat="centroid_lat", lon="centroid_lon",
8585
nx_hexagon=10, opacity=0.5, labels={"color": "Point Count"},
8686
min_count=1, color_continuous_scale="Viridis",
@@ -100,7 +100,7 @@ import numpy as np
100100
px.set_mapbox_access_token(open(".mapbox_token").read())
101101
df = px.data.carshare()
102102

103-
fig = ff.create_hexbin_mapbox(
103+
fig = ff.create_hexbin_map(
104104
data_frame=df, lat="centroid_lat", lon="centroid_lon",
105105
nx_hexagon=10, opacity=0.9, labels={"color": "Average Peak Hour"},
106106
color="peak_hour", agg_func=np.mean, color_continuous_scale="Icefire", range_color=[0,23]
@@ -118,7 +118,7 @@ import numpy as np
118118
px.set_mapbox_access_token(open(".mapbox_token").read())
119119
df = px.data.carshare()
120120

121-
fig = ff.create_hexbin_mapbox(
121+
fig = ff.create_hexbin_map(
122122
data_frame=df, lat="centroid_lat", lon="centroid_lon",
123123
nx_hexagon=10, opacity=0.9, labels={"color": "Summed Car.Hours"},
124124
color="car_hours", agg_func=np.sum, color_continuous_scale="Magma"
@@ -150,7 +150,7 @@ frame = np.concatenate([
150150
np.ones(N, int) * i for i in range(n_frames)
151151
])
152152

153-
fig = ff.create_hexbin_mapbox(
153+
fig = ff.create_hexbin_map(
154154
lat=lat, lon=lon, nx_hexagon=15, animation_frame=frame,
155155
color_continuous_scale="Cividis", labels={"color": "Point Count", "frame": "Period"},
156156
opacity=0.5, min_count=1,

plotly/figure_factory/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929

3030
if optional_imports.get_module("pandas") is not None:
3131
from plotly.figure_factory._county_choropleth import create_choropleth
32-
from plotly.figure_factory._hexbin_mapbox import create_hexbin_mapbox
32+
from plotly.figure_factory._hexbin_map import create_hexbin_map
3333
else:
3434

3535
def create_choropleth(*args, **kwargs):
3636
raise ImportError("Please install pandas to use `create_choropleth`")
3737

38-
def create_hexbin_mapbox(*args, **kwargs):
39-
raise ImportError("Please install pandas to use `create_hexbin_mapbox`")
38+
def create_hexbin_map(*args, **kwargs):
39+
raise ImportError("Please install pandas to use `create_hexbin_map`")
4040

4141

4242
if optional_imports.get_module("skimage") is not None:
@@ -57,7 +57,7 @@ def create_ternary_contour(*args, **kwargs):
5757
"create_distplot",
5858
"create_facet_grid",
5959
"create_gantt",
60-
"create_hexbin_mapbox",
60+
"create_hexbin_map",
6161
"create_ohlc",
6262
"create_quiver",
6363
"create_scatterplotmatrix",

plotly/figure_factory/_hexbin_mapbox.py renamed to plotly/figure_factory/_hexbin_map.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from plotly.express._chart_types import choropleth_map, scatter_map
44
import narwhals.stable.v1 as nw
55
import numpy as np
6+
import warnings
67

78

89
def _project_latlon_to_wgs84(lat, lon):
@@ -322,7 +323,7 @@ def _hexagons_to_geojson(hexagons_lats, hexagons_lons, ids=None):
322323
return dict(type="FeatureCollection", features=features)
323324

324325

325-
def create_hexbin_mapbox(
326+
def create_hexbin_map(
326327
data_frame=None,
327328
lat=None,
328329
lon=None,
@@ -339,7 +340,7 @@ def create_hexbin_mapbox(
339340
opacity=None,
340341
zoom=None,
341342
center=None,
342-
mapbox_style=None,
343+
map_style=None,
343344
title=None,
344345
template=None,
345346
width=None,
@@ -462,7 +463,7 @@ def create_hexbin_mapbox(
462463
opacity=opacity,
463464
zoom=zoom,
464465
center=center,
465-
map_style=mapbox_style,
466+
map_style=map_style,
466467
title=title,
467468
template=template,
468469
width=width,
@@ -502,8 +503,8 @@ def create_hexbin_mapbox(
502503
return fig
503504

504505

505-
create_hexbin_mapbox.__doc__ = make_docstring(
506-
create_hexbin_mapbox,
506+
create_hexbin_map.__doc__ = make_docstring(
507+
create_hexbin_map,
507508
override_dict=dict(
508509
nx_hexagon=["int", "Number of hexagons (horizontally) to be created"],
509510
agg_func=[
@@ -524,3 +525,16 @@ def create_hexbin_mapbox(
524525
original_data_marker=["dict", "Scattermap marker options."],
525526
),
526527
)
528+
529+
def create_hexbin_mapbox(*args, **kwargs):
530+
warnings.warn(
531+
"create_hexbin_mapbox() is deprecated and will be removed in the next major version. "
532+
+ "Please use create_hexbin_map() instead. "
533+
+ "Learn more at: https://plotly.com/python/mapbox-to-maplibre/",
534+
stacklevel=2,
535+
category=DeprecationWarning,
536+
)
537+
if "mapbox_style" in kwargs:
538+
kwargs["map_style"] = kwargs.pop("mapbox_style")
539+
540+
return create_hexbin_map(*args, **kwargs)

tests/test_optional/test_figure_factory/test_figure_factory.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4228,7 +4228,7 @@ def test_aggregation(self):
42284228
lon = [1, 2, 3, 3, 0, 4, 5, 0, 5, 3, 1, 5, 4, 0, 1, 2, 5]
42294229
color = np.ones(len(lat))
42304230

4231-
fig1 = ff.create_hexbin_mapbox(lat=lat, lon=lon, nx_hexagon=1)
4231+
fig1 = ff.create_hexbin_map(lat=lat, lon=lon, nx_hexagon=1)
42324232

42334233
actual_geojson = {
42344234
"type": "FeatureCollection",
@@ -4331,7 +4331,7 @@ def test_aggregation(self):
43314331
self.compare_dict_values(fig1.data[0].geojson, actual_geojson)
43324332
assert np.array_equal(fig1.data[0].z, actual_agg)
43334333

4334-
fig2 = ff.create_hexbin_mapbox(
4334+
fig2 = ff.create_hexbin_map(
43354335
lat=lat,
43364336
lon=lon,
43374337
nx_hexagon=1,
@@ -4341,7 +4341,7 @@ def test_aggregation(self):
43414341

43424342
assert np.array_equal(fig2.data[0].z, np.ones(5))
43434343

4344-
fig3 = ff.create_hexbin_mapbox(
4344+
fig3 = ff.create_hexbin_map(
43454345
lat=np.random.randn(1000),
43464346
lon=np.random.randn(1000),
43474347
nx_hexagon=20,
@@ -4364,8 +4364,8 @@ def test_build_dataframe(self):
43644364
columns=["Latitude", "Longitude", "Metric", "Frame"],
43654365
)
43664366

4367-
fig1 = ff.create_hexbin_mapbox(lat=lat, lon=lon, nx_hexagon=nx_hexagon)
4368-
fig2 = ff.create_hexbin_mapbox(
4367+
fig1 = ff.create_hexbin_map(lat=lat, lon=lon, nx_hexagon=nx_hexagon)
4368+
fig2 = ff.create_hexbin_map(
43694369
data_frame=df, lat="Latitude", lon="Longitude", nx_hexagon=nx_hexagon
43704370
)
43714371

@@ -4375,22 +4375,22 @@ def test_build_dataframe(self):
43754375
fig1.to_plotly_json()["data"][0], fig2.to_plotly_json()["data"][0]
43764376
)
43774377

4378-
fig3 = ff.create_hexbin_mapbox(
4378+
fig3 = ff.create_hexbin_map(
43794379
lat=lat,
43804380
lon=lon,
43814381
nx_hexagon=nx_hexagon,
43824382
color=color,
43834383
agg_func=np.sum,
43844384
min_count=0,
43854385
)
4386-
fig4 = ff.create_hexbin_mapbox(
4386+
fig4 = ff.create_hexbin_map(
43874387
lat=lat,
43884388
lon=lon,
43894389
nx_hexagon=nx_hexagon,
43904390
color=color,
43914391
agg_func=np.sum,
43924392
)
4393-
fig5 = ff.create_hexbin_mapbox(
4393+
fig5 = ff.create_hexbin_map(
43944394
data_frame=df,
43954395
lat="Latitude",
43964396
lon="Longitude",
@@ -4406,7 +4406,7 @@ def test_build_dataframe(self):
44064406
fig4.to_plotly_json()["data"][0], fig5.to_plotly_json()["data"][0]
44074407
)
44084408

4409-
fig6 = ff.create_hexbin_mapbox(
4409+
fig6 = ff.create_hexbin_map(
44104410
data_frame=df,
44114411
lat="Latitude",
44124412
lon="Longitude",
@@ -4416,7 +4416,7 @@ def test_build_dataframe(self):
44164416
animation_frame="Frame",
44174417
)
44184418

4419-
fig7 = ff.create_hexbin_mapbox(
4419+
fig7 = ff.create_hexbin_map(
44204420
lat=lat,
44214421
lon=lon,
44224422
nx_hexagon=nx_hexagon,

0 commit comments

Comments
 (0)