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

[BUG]The plot disappears when I click on a Rank legend for POSIX data #317

Open
aparajit7 opened this issue Sep 4, 2024 · 7 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@aparajit7
Copy link

aparajit7 commented Sep 4, 2024

Describe the bug 🖍️

The entire POSIX plot disappears when I click on an individual rank to visualize the data.

Reproducing the bug 🔍

   import plotly.graph_objects as go
   from dash import Dash, html, dcc
   from plotly_resampler import FigureResampler, register_plotly_resampler
   import pandas as pd
   import numpy as np
   import time


   df = pd.read_csv('sample-enlarged.csv')


  df['mark'] = (df['start'] + df['end']) / 2
  df['mark_size'] = (df['end'] - df['start']) / 2
  df['rank'] = df['rank'].astype("category")
  df['color'] = '#000000'
  df.loc[df['operation'] == 'write', 'color'] = 'blue'
  df.loc[df['operation'] == 'read', 'color'] = 'red'

  df = df.sort_values(by=['mark'])
  df['mark'] = df['mark'].interpolate()

  df = df[df['api'] == 'POSIX']

  register_plotly_resampler(
     mode="LTTB",  
     default_n_shown_samples=500,  
  )

  fig = FigureResampler(go.Figure())
  start_time = time.time()

  for rank in df["rank"].unique():
     df_rank = df[df["rank"] == rank]
    
    
     df_sample = df_rank.sample(100)

     fig.add_trace(
         go.Scattergl(
             x=df_sample["mark"],
             y=df_sample["rank"],
             name=f'Rank {rank}',
             marker=dict(
                 color=df_sample["color"].iloc[0], 
             ),
             line=dict(
                 color=df_sample["color"].iloc[0],  
             ),
             error_x=dict(
                 type='data',  
                 symmetric=True,
                 array=df_sample["mark_size"],
                 color=df_sample["color"].iloc[0],
                 visible=True,
                 thickness=6,
                 width=0
             ),
             showlegend=True
         ),
         hf_x=df_rank["mark"],  
         hf_y=df_rank["rank"]
     )

  end_time = time.time()
  print(f"Script runtime: {end_time - start_time:.2f} seconds")

  app = Dash(__name__)

  app.layout = html.Div(children=[dcc.Graph(id="graph-id", figure=fig)])


  fig.register_update_graph_callback(app, "graph-id")

  if __name__ == '__main__':
      app.run(debug=True)

This is the code that I am currently working with

Expected behavior 🔧

I expected the plot to only eliminate the rank I clicked on not make the whole plot disappear.

Screenshots 📸

image
image
When I selected the rank marked in red the entire plot disappeared

Environment information: (please complete the following information)

  • OS: Ubuntu 22.04.3
  • Python environment:
    • Python version: 3.10.12
    • plotly-resampler environment: e.g.: Jupyter(lab), Dash web app (which browser): Visual Studio Code, Google Chrome (web browser)
  • plotly-resampler version:0.10.0

Additional context
Add any other context about the problem here.

@aparajit7 aparajit7 added the bug Something isn't working label Sep 4, 2024
@jonasvdd jonasvdd self-assigned this Sep 4, 2024
@jonasvdd
Copy link
Member

jonasvdd commented Sep 5, 2024

@aparajit7, could you share a minimal csv file, similar to sample-enlarged.csv, for which this behavior occurs?

@aparajit7
Copy link
Author

aparajit7 commented Sep 6, 2024 via email

@jonasvdd
Copy link
Member

jonasvdd commented Sep 6, 2024

@aparajit7 - The access was denied, so I sent an access request.

@aparajit7
Copy link
Author

aparajit7 commented Sep 6, 2024 via email

@jonasvdd
Copy link
Member

jonasvdd commented Sep 9, 2024

@aparajit7,

It appears to be related to the error_x attribute. If you leave this out, everything works as expected.
Plotly-Resampler does not (yet) support this attribute.

@aparajit7
Copy link
Author

aparajit7 commented Sep 16, 2024 via email

@aparajit7
Copy link
Author

aparajit7 commented Oct 1, 2024 via email

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

2 participants