# Disable interactions in Plotly for R and ggplot2

**URL:** <https://community.plotly.com/t/disable-interactions-in-plotly-for-r-and-ggplot2/1361>\
**Category:** Plotly R\
**Created:** [June 22, 2016, 1:33pm UTC](https://community.plotly.com/t/disable-interactions-in-plotly-for-r-and-ggplot2/1361 "2016-06-22T13:33:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bostonwalker](https://avatars.discourse-cdn.com/v4/letter/b/5f8ce5/32.png) [@bostonwalker](https://community.plotly.com/u/bostonwalker)\
**Post date:** [June 22, 2016, 1:33pm UTC](https://community.plotly.com/t/disable-interactions-in-plotly-for-r-and-ggplot2/1361/1 "2016-06-22T13:33:29Z")

</div>

Hi [plot.ly](http://plot.ly),

I want to achieve the following two things using [plot.ly](http://plot.ly) R API and the ggplotly function:

- Remove components from the action bar and/or the whole action bar
- Disable zoom/pan/stretch

Is there a way to do this without writing JS?

---

<div class="post-metadata">

**Author:** ![daftmath](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@daftmath](https://community.plotly.com/u/daftmath)\
**Post date:** [June 22, 2016, 3:48pm UTC](https://community.plotly.com/t/disable-interactions-in-plotly-for-r-and-ggplot2/1361/2 "2016-06-22T15:48:21Z")

</div>

Pass a FALSE to the config value _displayModeBar_ to disable the little action bar. To stop the zooming pass TRUE to the _fixedrange_ layout option for each respective axis.

Example:

> library(plotly)  
> set.seed(100)  
> d ← diamonds[sample(nrow(diamonds), 1000),]  
> plot\_ly(d, x = carat, y = price, text = paste("Clarity: ", clarity),  
> mode = “markers”, color = carat, size = carat) %\>% config(displayModeBar = F) %\>% layout(xaxis=list(fixedrange=TRUE)) %\>% layout(yaxis=list(fixedrange=TRUE))

 ![](https://us1.discourse-cdn.com/flex024/uploads/plot/original/1X/4c52e42d5d5a7bda6fdd812ac888c51882e08bba.png)

---

<div class="post-metadata">

**Author:** ![bostonwalker](https://avatars.discourse-cdn.com/v4/letter/b/5f8ce5/32.png) [@bostonwalker](https://community.plotly.com/u/bostonwalker)\
**Post date:** [June 22, 2016, 4:10pm UTC](https://community.plotly.com/t/disable-interactions-in-plotly-for-r-and-ggplot2/1361/3 "2016-06-22T16:10:58Z")

</div>

What about with ggplotly()?

---

<div class="post-metadata">

**Author:** ![daftmath](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@daftmath](https://community.plotly.com/u/daftmath)\
**Post date:** [June 22, 2016, 4:54pm UTC](https://community.plotly.com/t/disable-interactions-in-plotly-for-r-and-ggplot2/1361/4 "2016-06-22T16:54:09Z")

</div>

It is handled the same way; a ggplotly object is a plotly object.

```
p <- ggplot(data = d, aes(x = carat, y = price)) +
  geom_point(aes(text = paste("Clarity:", clarity)), size = 4) +
  geom_smooth(aes(colour = cut, fill = cut))

ggplotly(p) %>% config(displayModeBar = F) %>% layout(xaxis=list(fixedrange=TRUE)) %>% layout(yaxis=list(fixedrange=TRUE))

```

 ![](https://us1.discourse-cdn.com/flex024/uploads/plot/original/1X/369992fa1c25cf823388849c7739fd6634a81236.png)
