Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding shapes or multiple traces on figure cause zoom issue #7

Open
jeffreyleifer opened this issue Jun 24, 2021 · 1 comment
Open
Assignees
Labels
bug Something isn't working

Comments

@jeffreyleifer
Copy link

When adding lines or shapes or additional traces, the zoom relayout produces an incomplete trace

Test code, using vline

# First let's create a Dash application
import dash
import dash_core_components as dcc
import dash_html_components as html
import numpy as np
import plotly.graph_objects as go
from dash.dependencies import Input, Output
from lenspy import DynamicPlot

app = dash.Dash()

# Now let's make a large plot we want to include in the app
x = np.arange(1, 11, 1e-6)
y = 1e-2*np.sin(1e3*x) + np.sin(x) + 1e-3*np.sin(1e10*x)
fig = go.Figure(data=[go.Scattergl(x=x, y=y)])
fig.add_vline(x=(5), line_width=1, line_dash="dash", line_color="red")
fig.add_vline(x=(2), line_width=1, line_dash="dash", line_color="red")
fig.add_vline(x=(7), line_width=1, line_dash="dash", line_color="red")
fig.update_layout(title=f"{len(x):,} Data Points.")

plot = DynamicPlot(fig)

# Use dcc.Graph to create a component with your DynamicPlot
graph_cc = dcc.Graph(id="my_plot",
                    figure=plot.fig,
                    style={"height": "100%", "width": "100%"})

# Add the graph to the app's layout
app.layout = html.Div([graph_cc])

# Create a callback to update the plot on layout changes
app.callback(
    Output("my_plot", "figure"),
    [Input("my_plot", "relayoutData")]
)(plot.refine_plot)

# Run the application
app.run_server()

Axis Home:
image
Zoomed:
image

@serant serant self-assigned this Mar 5, 2022
@serant serant added the bug Something isn't working label Mar 5, 2022
@koni-ey
Copy link

koni-ey commented Mar 24, 2022

Similar or maybe related problem when using plotly.subplots.. weird zoom behavior that auto-resets after every refinemend when not using the "first" plot to zoom..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants