deephaven / deephaven-plugins

Deephaven Plugins
6 stars 14 forks source link

Incorrect axes when deephaven.ui wraps legacy plot #622

Open jnumainville opened 3 weeks ago

jnumainville commented 3 weeks ago

Description

In the provided code, the axes on the "double" plot seem to get mixed up

Steps to reproduce

from deephaven import read_csv
from deephaven.plot.figure import Figure

source = read_csv(
    "https://media.githubusercontent.com/media/deephaven/examples/main/MetricCentury/csv/metriccentury.csv"
)

@ui.component
def dashboard():
    type, set_type = ui.use_state("single")
    return [
        ui.panel(
            ui.button("Plot Single", on_press=lambda: set_type("single")),
            ui.button("Plot Double", on_press=lambda: set_type("double"))
        ),
        ui.panel(
            Figure().plot_xy(series_name="Altitude", t=source, x="Time", y="AltitudeMeters").show()
        ) if type == "single" else
        ui.panel(
            Figure().plot_xy(series_name="Altitude", t=source, x="Time", y="AltitudeMeters").x_twin().plot_xy(series_name="Speed", t=source, x="Time", y="SpeedKPH").show()
        )
    ]

dash = dashboard()

Expected results

The axes output the same as if the plot is standalone

Figure().plot_xy(series_name="Altitude", t=source, x="Time", y="AltitudeMeters").x_twin().plot_xy(series_name="Speed", t=source, x="Time", y="SpeedKPH").show()

Actual results

The axes are mixed up