Get help from the marimo community

Updated last month

Preventing infinite loop when variable can be updated from 2 sources

At a glance

The community member is trying to create a Marimo app with two scatterplots side-by-side, where hovering over a circle in one plot should highlight the corresponding circle in the other plot. The community member has an array of data points with properties id, x, y, and z, and is using svg.py to create the plots. The community member is looking for a "Marimo way" to approach this problem.

In the comments, another community member suggests using traitlets.link to solve the issue, and mentions that Marimo also has mo.state which is an advanced topic that may not be necessary in this case.

Useful resources
I'm trying to create a small marimo app that shows 2 scatterplots next to each other. These are just 2 simple SVGs, using svg.py. (That's important because the app is just a proof-of-principle for more complex novel visualisations later). The setup is the following:

  • I have an array of datapoints with the properties id, x, y and z.
  • I create 2 SVGs based on that array (let's say one plots x vs y, the other plots x vs z).
  • When hovering over a circle in 1 plot, I can get the ID of that circle.
  • I want to have the circle with the same ID but in the second plot to react as well.
What is a good "marimo" way to approach this? Basically, both plots can be the input for the "selected" ID, and both should change when that ID changes.
J
M
2 comments
I have it working. @manzt helped me out. The trick is to use traitlets.link.
That’s a great approach and works well. We also have ‘mo.state’ which is advanced topic and likely can be avoided https://docs.marimo.io/guides/state/
Add a reply
Sign up and join the conversation on Discord