Skip to content

Incorrect input values of mouse event position with {plotnine} #1007

@youngroklee-ml

Description

@youngroklee-ml

When getting mouse event on ui.output_plot(), e.g., click, brush, etc., the input value accessed in the server does not correctly represents user's input on a plot.

For example, a snapshot below shows that I dragged a region for [2, 3] on x-axis and [20, 30] on y-axis, but the input values were read as [1.7, 2.9] for x-axis and [21.9, 30.6] for y-axis.

plotnine-brush-position

Below is an app code:

from shiny import App, render, ui, req
from plotnine import ggplot, aes, geom_point
from pydataset import data

mtcars = data("mtcars")

app_ui = ui.page_fluid(
    ui.output_plot("plot", brush=True),
    ui.output_text_verbatim("info"),
)

def server(input, output, session):
    @render.plot
    def plot():
        res = (ggplot(mtcars, aes('wt', 'mpg'))
               + geom_point())
        return res
    
    @render.text
    def info():
        req(input.plot_brush())
        return input.plot_brush()

app = App(app_ui, server)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions