Skip to content

Closing radar chart with plotly go.Scatterpolar #533

Description

@leomignot

Hi,

On this page, the radar charts created with plotly graph objects (go.Scatterpolar) do not close — the line connecting the last point back to the first is missing.

Clearly not on you; this is so typical that the official Plotly documentation does it.

The usual line_close=True method from Plotly Express does not work with Graph Objects. And fig.update_traces(connectgaps=True) does not seem to work with radar coordinates.

A possible workaround (mentioned here) is to manually close the loop by repeating the first point in r and theta:

r = df["value"].tolist() + [df["value"][0]]
theta = df["name"].tolist() + [df["name"][0]]

or

r = [*df["value"], df["value"].iloc[0]]
theta = [*df["name"], df["name"].iloc[0]]

It’s stupid, verbose and inelegant, but (on the plus size) it works.

I haven’t made a PR because this might be too niche to implement (after all, the same behavior exists on the official Plotly site), but I can submit one if needed.

PS: I'm bad at it. I might not be aware of a cleaner solution, so there could be a better way.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions