Wednesday, July 3, 2024
HomeLanguagesPythonHow 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

 

Nango Kalahttps://www.kala.co.za
Experienced Support Engineer with a demonstrated history of working in the information technology and services industry. Skilled in Microsoft Excel, Customer Service, Microsoft Word, Technical Support, and Microsoft Office. Strong information technology professional with a Microsoft Certificate Solutions Expert (Privet Cloud) focused in Information Technology from Broadband Collage Of Technology.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments