Myles Scolnick
Myles Scolnick5mo ago

dataframe corresponding to brushed segment of a plotly scatterplot

This is more of a python question, but is there a way to return dataframe corresponding to brushed segment of a plotly scatterplot? Similar to altair. - @Mustjaab
Solution:
@Mustjaab , you should be able to do something like ```python import plotly.express as px import marimo as mo...
Jump to solution
1 Reply
Solution
Myles Scolnick
Myles Scolnick5mo ago
@Mustjaab , you should be able to do something like
import plotly.express as px
import marimo as mo
from vega_datasets import data
import polars as pl # or pandas

_plot = px.scatter(
data.cars(), x="Horsepower", y="Miles_per_Gallon", color="Origin"
)
plot = mo.ui.plotly(_plot)

# in another cell
df = pl.DataFrame(plot.value)
df
import plotly.express as px
import marimo as mo
from vega_datasets import data
import polars as pl # or pandas

_plot = px.scatter(
data.cars(), x="Horsepower", y="Miles_per_Gallon", color="Origin"
)
plot = mo.ui.plotly(_plot)

# in another cell
df = pl.DataFrame(plot.value)
df