Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

create_hexbin_mapbox uses *_map chart types instead of *_mapbox #5358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
emilykl merged 10 commits into plotly:main from ajlien:update-hexbin-map-no-mapbox
Oct 22, 2025

Conversation

@ajlien
Copy link
Contributor

@ajlien ajlien commented Oct 1, 2025
edited
Loading

  • I have read through the contributing notes and understand the structure of the package. In particular, if my PR modifies code of plotly.graph_objects, my modifications concern the code generator and not the generated files.
  • I have added tests or modified existing tests.
  • For a new feature, I have added documentation examples (please see the doc checklist as well).
  • I have added a CHANGELOG entry if changing anything substantial.
  • For a new feature or a change in behavior, I have updated the relevant docstrings in the code.

Small change to remove mapbox references from figure factory's hexbin map. See #5081 in particular @danielsaaf's comment.

No (削除) docstrings or (削除ここまで) kwarg names needed to be changed, this is just a substitution.

As a side effect (and the reason I originally came across this issue), currrently if you construct a figure with create_hexbin_mapbox then add another go.Scattermap trace to it, any maki symbols in the scattermap will not render. This PR also fixes that.

Copy link
Contributor Author

ajlien commented Oct 1, 2025

Copy link
Contributor Author

ajlien commented Oct 1, 2025

Looks like they failed on the same Python code block (1), (2):

import plotly.express as px
from skimage import io
img = io.imread('https://upload.wikimedia.org/wikipedia/commons/thumb/0/00/Crab_Nebula.jpg/240px-Crab_Nebula.jpg')
fig = px.imshow(img)
fig.show()

with

HTTPError: HTTP Error 403: Forbidden

Did upload.wikimedia.org block the resource request?

Copy link
Contributor

emilykl commented Oct 1, 2025

Hi @ajlien , thanks for catching this, we should definitely migrate this function to use _map traces.

The doc build failure has been fixed on main, if you merge main into your branch the issue should be resolved.

We should also deprecate create_hexbin_mapbox() and rename it to create_hexbin_map(). Could you add the following changes to this branch?

  • Rename the function from create_hexbin_mapbox() to create_hexbin_map()
  • Rename the mapbox_style arg to map_style
  • Add a new create_hexbin_mapbox() function which shows a DeprecationWarning and then calls create_hexbin_map(), i.e. something like this:
def create_hexbin_mapbox(*args, **kwargs):
 warnings.warn(
 "create_hexbin_mapbox() is deprecated and will be removed in the next major version. "
 + "Please use create_hexbin_map() instead. "
 + "Learn more at: https://plotly.com/python/mapbox-to-maplibre/",
 stacklevel=2,
 category=DeprecationWarning,
 )
 if "mapbox_style" in kwargs:
 kwargs["map_style"] = kwargs.pop("mapbox_style")
 return create_hexbin_map(*args, **kwargs) 
  • Update plotly/figure_factory/__init__.py accordingly

I'm happy to take over this branch if you don't have the bandwidth, but if you get around to it first, go for it! Thanks again.

Copy link
Contributor Author

ajlien commented Oct 3, 2025 via email

Thanks Emily! Can do today.
...
On Wed, Oct 1, 2025, 4:48 PM Emily KL ***@***.***> wrote: *emilykl* left a comment (plotly/plotly.py#5358) <#5358 (comment)> Hi @ajlien <https://github.com/ajlien> , thanks for catching this, we should definitely migrate this function to use _map traces. The doc build failure has been fixed on main, if you merge main into your branch the issue should be resolved. We should also deprecate create_hexbin_mapbox() and rename it to create_hexbin_map(). Could you add the following changes to this branch? - Rename the function from create_hexbin_mapbox() to create_hexbin_map() - Rename the mapbox_style arg to map_style - Add a new create_hexbin_mapbox() function which shows a DeprecationWarning and then calls create_hexbin_map(), i.e. something like this: def create_hexbin_mapbox(*args, **kwargs): warnings.warn( "create_hexbin_mapbox() is deprecated and will be removed in the next major version. " + "Please use create_hexbin_map() instead. " + "Learn more at: https://plotly.com/python/mapbox-to-maplibre/", stacklevel=2, category=DeprecationWarning, ) if "mapbox_style" in kwargs: kwargs["map_style"] = kwargs.pop("mapbox_style") return create_hexbin_map(*args, **kwargs) - Update plotly/figure_factory/__init__.py accordingly I'm happy to take over this branch if you don't have the bandwidth, but if you get around to it first, go for it! Thanks again. — Reply to this email directly, view it on GitHub <#5358 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AFOQA5YR7KS3USQPF6KHDAL3VQ4YHAVCNFSM6AAAAACIAXVOCOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTGNJYGA4DANBTHE> . You are receiving this because you were mentioned.Message ID: ***@***.***>

Copy link
Contributor

gvwilson commented Oct 7, 2025

thanks @ajlien - this looks good to me. If @emilykl approves as well, we'll get it merged.

@gvwilson gvwilson added P1 needed for current cycle community community contribution fix fixes something broken labels Oct 7, 2025
Copy link
Contributor Author

ajlien commented Oct 22, 2025

Hi @emilykl, just pushed commits reflecting your requested changes.

Please note that I did not update the Reference section of doc/python/hexbin-mapbox.md, as I'm not sure whether this would break existing URLs.

if optional_imports.get_module("pandas") is not None:
from plotly.figure_factory._county_choropleth import create_choropleth
from plotly.figure_factory._hexbin_mapbox import create_hexbin_mapbox
from plotly.figure_factory._hexbin_map import create_hexbin_map
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from plotly.figure_factory._hexbin_map import create_hexbin_map
from plotly.figure_factory._hexbin_map import create_hexbin_map, create_hexbin_mapbox

Comment on lines +38 to +39
def create_hexbin_map(*args, **kwargs):
raise ImportError("Please install pandas to use `create_hexbin_map`")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def create_hexbin_map(*args, **kwargs):
raise ImportError("Please install pandas to use `create_hexbin_map`")
def create_hexbin_map(*args, **kwargs):
raise ImportError("Please install pandas to use `create_hexbin_map`")
def create_hexbin_mapbox(*args, **kwargs):
raise ImportError("Please install pandas to use `create_hexbin_mapbox`")

Copy link
Contributor

emilykl commented Oct 22, 2025

Thank you @ajlien! Just need to add create_hexbin_mapbox in a few places in the figure_factory/__init__.py (see suggestions), otherwise LGTM!

df = px.data.carshare()

fig = ff.create_hexbin_mapbox(
fig = ff.create_hexbin_map(
Copy link
Member

@LiamConnors LiamConnors Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove the px.set_mapbox_access_token(open(".mapbox_token").read()) lines in these examples and the information about mapbox tokens in the introduction.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 9773b5

Copy link
Contributor

@emilykl emilykl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR @ajlien ! 🚀

@emilykl emilykl merged commit 9c18a8b into plotly:main Oct 22, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@LiamConnors LiamConnors LiamConnors left review comments

@gvwilson gvwilson gvwilson approved these changes

@emilykl emilykl emilykl approved these changes

Labels

community community contribution fix fixes something broken P1 needed for current cycle

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /