Skip to content

Cannot plot multiple graphs using plotly in for loop #706

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

Open
Harshal12355 opened this issue Apr 24, 2025 · 2 comments
Open

Cannot plot multiple graphs using plotly in for loop #706

Harshal12355 opened this issue Apr 24, 2025 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@Harshal12355
Copy link

Is your feature request related to a problem? Please describe.

Yes. When trying to generate multiple Plotly graphs in a loop—e.g., comparing one feature against a list of others—you’re required to manually assign a unique id to each graph. This requirement isn’t mentioned in the documentation, and without it, the function doesn’t work as expected. This makes it difficult to automate plotting in batch.

Describe the solution you'd like

The function should automatically assign unique ids (e.g., using uuid or hash values) when generating multiple plots. Alternatively, the documentation should clearly state that a unique id must be provided when plotting dynamically.

Describe alternatives you've considered

I’ve worked around this by generating uuids manually for each graph (enumerating through the list), but it’s not ideal for workflows with many plots. Especially if you do this for multiple plots, they are bound conflict at different parts of the code base.

Additional context

This issue significantly limits the usability of the function for dynamic or large-scale plotting. Automating id assignment or improving the docs would greatly improve the developer experience.

@Harshal12355 Harshal12355 added the enhancement New feature or request label Apr 24, 2025
@shivam-singhal
Copy link
Member

@BloggerBust I think this might interest you!

@Harshal12355 we are working on fixing this soon!

@BloggerBust
Copy link
Collaborator

Thanks so much for raising this, @Harshal12355!

You’re absolutely right that dynamically generated components in loops require a manual workaround to avoid ID collisions, and the behavior isn’t clearly documented.

We’ve addressed this in PR #712, which introduces a new reactive runtime with AST-based analysis and DAG-driven reruns. Components are now automatically assigned stable identifiers to ensure consistent behavior and in dynamic contexts, you can provide your own identifier that will be hashed as part of the stable identifier:

for i in range(3):
    text(f"Item {i}", identifier=f"text-{i}")

📄 See the updated docs

This ensures stable component IDs and atom names even in loops, which avoids collisions and preserves reactivity.

Appreciate you flagging this! Let us know if you hit any other rough edges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants