# Exchange data in scatterplot by button

**URL:** <https://community.plotly.com/t/exchange-data-in-scatterplot-by-button/43620>\
**Category:** 📊 Plotly Python\
**Created:** [August 10, 2020, 12:57pm UTC](https://community.plotly.com/t/exchange-data-in-scatterplot-by-button/43620 "2020-08-10T12:57:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![samir](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@samir](https://community.plotly.com/u/samir)\
**Post date:** [August 10, 2020, 12:57pm UTC](https://community.plotly.com/t/exchange-data-in-scatterplot-by-button/43620/1 "2020-08-10T12:57:51Z")

</div>

Hi,

I am trying to exchange the data in a scatter plot via a button. I would like to replace the data, not hide it (`visible = False`). I am following the examples here: [https://plotly.com/python/custom-buttons/#update-button](https://plotly.com/python/custom-buttons/#update-button)

This is my code that I think should work given the examples in the link above. However, the data displayed does not change. How can I make this work?

```auto
import pandas as pd
import plotly.graph_objects as go

df = pd.DataFrame(dict(a=[1, 2, 3], b=[1, 2, 3], c=[4, 8, 6]))

fig = go.Figure()

fig.add_trace(go.Scatter(x=df.a, y=df.b, mode="markers"))

fig.update_layout(
    updatemenus=[
        dict(
            type="buttons",
            direction="right",
            x=0.6,
            y=1.2,
            showactive=True,
            buttons=list(
                [
                    dict(label="B", method="restyle", args=["y", df["b"]]),
                    dict(label="C", method="restyle", args=["y", df["c"]]),
                ]
            ),
        )
    ]
)

fig.show()

```

I also tried data.y, scatter.y, scatter.data.y etc. nothing helps.  
Thanks a lot!

Edit: I works with `args=["y", [df.c]]`

---

<div class="post-metadata">

**Author:** ![samir](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@samir](https://community.plotly.com/u/samir)\
**Post date:** [August 10, 2020, 1:13pm UTC](https://community.plotly.com/t/exchange-data-in-scatterplot-by-button/43620/2 "2020-08-10T13:13:44Z")

</div>

It works with `args=["y", [df.c]]`. However, this is curious given `y` is supposed to digest " _Type:_ list, numpy array, or Pandas series of numbers, strings, or datetimes."
