Skip to content

Choropleth: can't add/remove from current selection after zoom #7391

Open
@araichev

Description

@araichev

I don't know if this is a bug or a missing feature, but i'd like to select polygons on a choropleth, zoom, then add/ remove from the current selection via shift+click.
This is especially useful when i want to remove a few central polygons from a big selection small polygons and need to select then zoom in to better see which few to remove.
This is already possible in (non-geographic) scatter plots: click to select, zoom, then shift-click to remove from selection, e.g.

import plotly.express as px

df = px.data.iris()
fig = px.scatter(df.iloc[:20], x="sepal_width", y="sepal_length")
fig.update_layout(clickmode="event+select")
fig.show()

And it's already possible in choropleths without zooming between selecting and shift-clicking.

Here's a code snippet to reproduce the bug (or missing feature).

import plotly.graph_objects as go

import pandas as pd
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2011_us_ag_exports.csv')

fig = go.Figure(data=go.Choropleth(
    locations=df['code'], # Spatial coordinates
    z = df['total exports'].astype(float), # Data to be color-coded
    locationmode = 'USA-states', # set of locations match entries in `locations`
    colorscale = 'Reds',
    colorbar_title = "Millions USD",
))

fig.update_layout(
    title_text = '2011 US Agriculture Exports by State',
    geo_scope='usa', # limite map scope to USA
    clickmode="event+select",
)

fig.show()

Now box-select some polygons, then remove a polygon from the selection by shift-clicking it.
Works nicely.
Box-select some polygons again, zoom in, then try to remove a polygon from the selection by shift-clicking it.
No can do!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlogbugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions