Skip to content

Problems with coordinate mapping computation in Shiny #738

@wch

Description

@wch

Shiny is having a problem with calculating coordinate information with the release version of Plotnine.

I'll demonstrate with this app from the shinylive examples: https://shinylive.io/py/examples/#basic-plot-interaction

With this screenshot, the cursor is at (4, 25), and the x and y coordinates are detected to be right on, at (4.0, 25.0). Note that this is with shinylive, which uses a custom build of plotnine that avoids the problem. (https://github.com/wch/plotnine/tree/fix-dims)

image

If I save the files from that app and run it with regular Python (not shinylive) using shiny 0.6.1.1 and plotnine 0.12.4 installed from PyPI, it demonstrates the problem -- the detected coordinates are slightly off, at (4.27, 25.9):

image

The code in Shiny that extracts the coordmap information is here. It basically finds the mapping between the pixel coordinate space and the data coordinate space. I believe that in the release version of plotnine, the detection of the pixel coordinate space is not correct.

https://github.com/posit-dev/py-shiny/blob/53c46fd6f71c5b19def29d1e94cae997bf93c5e0/shiny/render/_coordmap.py#L128-L200

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions