plotly / plotly/plotly.js

Invalid property specified for object of type plotly.graph_objs.scattermap.Textfont: 'shadow'

Open
#7,419 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature P3
Dominant language
JavaScript
Stars
18.3k
Forks
2k
Avg merge
2d 12h
Merged PRs (30d)
28

Description

Hello,

First, thank you for your work.

It seems like the text "shadow" parameter (here in the doc) is missing for go.Scattermap objects.
Without this parameter, we are unable to create visible labels on maps: this is the same problem as report here.

Here is an example of the problem and why border/shadow is required:
Image

Here is a minimum reproducible code

import plotly.graph_objects as go

# Sample data
data = {
    "label": ["New York", "Los Angeles", "Chicago"],
    "latitude": [40.7128, 34.0522, 41.8781],
    "longitude": [-74.0060, -118.2437, -87.6298]
}

# Create a Scattermapbox trace
go.Figure(
    go.Scattermap(
        lat=data["latitude"],
        lon=data["longitude"],
        text=data["label"],
        textfont={
            "color": "white",
            "size": 12,
            #"shadow": "1px 1px 1px black"  # THIS IS THE ISSUE 
        },
        mode="text",
    )
)
# Update layout to include a map style and center
fig.update_layout(
    map=dict(
        style="open-street-map",
        center=dict(lat=37.0902, lon=-95.7129),  # Centered over the USA
        zoom=3
    ),
    margin={"r":0,"t":0,"l":0,"b":0}
)

fig.show()

Result :
Image
This time the labels are white and require black shadow/border to be visible.

Plotly version: 5.24.0
python version: 5.11.11

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Scattermap's textfont support and compare it with the text-and-annotations documentation and the linked plotly.js issue. Reproduce the example with white labels, then determine the expected shadow behavior and verify that the shadow property is accepted and makes the labels visible.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.