# R plotly button

**URL:** <https://community.plotly.com/t/r-plotly-button/9697>\
**Category:** Plotly R\
**Created:** [April 15, 2018, 8:02pm UTC](https://community.plotly.com/t/r-plotly-button/9697 "2018-04-15T20:02:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![afrc](https://avatars.discourse-cdn.com/v4/letter/a/a9a28c/32.png) [@afrc](https://community.plotly.com/u/afrc)\
**Post date:** [April 15, 2018, 8:02pm UTC](https://community.plotly.com/t/r-plotly-button/9697/1 "2018-04-15T20:02:58Z")

</div>

Hi.

I want to creat a graph in plotly and i want a button to change de marker type in updatemenus, like square and circle and cross

Can you help me with a example?

Thanks 😉

---

<div class="post-metadata">

**Author:** ![bcd](https://avatars.discourse-cdn.com/v4/letter/b/ec9cab/32.png) [@bcd](https://community.plotly.com/u/bcd)\
**Post date:** [April 16, 2018, 11:27am UTC](https://community.plotly.com/t/r-plotly-button/9697/2 "2018-04-16T11:27:49Z")

</div>

Hi @afrc

You can try something like below. For more examples see Plotly’s docs [https://plot.ly/r/#controls](https://plot.ly/r/#controls)

```
library(plotly)

df <- data.frame(x = c(1,2,3,4,5), y1 = c(5,5,5,5,5))

p <- plot_ly(df, x = ~x, y = ~y1, mode = 'markers')

p <- p %>% layout(
  title = "Button Restyle",
  xaxis = list(domain = c(0.1, 1)),
  yaxis = list(title = "y"),
  updatemenus = list(
    list(
      type = "buttons",
      y = 0.8,
      buttons = list(
        
        list(method = "restyle",
             args = list("marker.symbol", "circle"),
             label = "Circle"),
        
        list(method = "restyle",
             args = list("marker.symbol", "square"),
             label = "Square")))
  ))
```

---

<div class="post-metadata">

**Author:** ![afrc](https://avatars.discourse-cdn.com/v4/letter/a/a9a28c/32.png) [@afrc](https://community.plotly.com/u/afrc)\
**Post date:** [April 23, 2018, 5:52pm UTC](https://community.plotly.com/t/r-plotly-button/9697/3 "2018-04-23T17:52:06Z")

</div>

thanks a lot 😉  
got it !!!
