Tuesday, November 19, 2024
Google search engine
HomeLanguagesHow to Hide the Floating Toolbar in Plotly in Python

How to Hide the Floating Toolbar in Plotly in Python

In this article, we’ll see an easy way to hide the floating toolbar in Python Plotly using Python. When we hover the mouse pointer over the chart, we see a floating toolbar with a set of tools. At times, this toolbar can be a distraction. We just want the chart to appear without a floating toolbar to avoid distractions since we’re not always sure what tool to use on our chart. Here, we will cover 3 examples as mentioned below:

  • Plot with the floating toolbar in Plotly
  • Plot without the floating toolbar in Plotly
  • Plot with the fixed toolbar in Plotly

Examples to Hide the floating toolbar in Plotly

Plot with the Floating Toolbar in Plotly

By default, the toolbar is only visible when we hover the mouse pointer over the chart. we see a floating toolbar with a set of tools.

Python3




import plotly.express as px
  
# using the dataset
df = px.data.tips()
  
# plotting the scatter chart
plot = px.scatter(df, x='total_bill', y="tip")
  
# showing the plot with the floating toolbar
plot.show()


Output:

Plot with the Floating Toolbar in Plotly

 

Plot without the Floating Toolbar in Plotly

The .show() method that we all use to display our figures also accepts a config parameter to help us change the configuration of the chart by passing a dictionary to the config parameter which contains the options which we want to set. If we want the floating toolbar to never be visible, set the displayModeBar property to False in the figure configuration.

plot.show(config = {'displayModeBar': False})

Python3




import plotly.express as px
  
# using the dataset
df = px.data.tips()
  
# plotting the scatter chart
plot = px.scatter(df, x='total_bill', y="tip")
  
# showing the plot without floating toolbar in Plotly
plot.show(config={'displayModeBar': False})


Output:

Plot without the Floating Toolbar in Plotly

 

Plot with the Fixed Toolbar in Plotly

By default, the toolbar is only visible when we hover the mouse pointer over the chart. If we want the toolbar to always be visible, regardless of whether the user is currently hovering over the figure, set the displayModeBar property to True in the figure configuration.

plot.show(config = {'displayModeBar': True})

Python3




import plotly.express as px
  
# using the dataset
df = px.data.tips()
  
# plotting the scatter chart
plot = px.scatter(df, x='total_bill', y="tip")
  
# showing the plot with fixed floating toolbar in Plotly
plot.show(config={'displayModeBar': True})


Output:

Plot with the Fixed Toolbar in Plotly

 

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments