Is it possible to disable the zoom/pan window on a plotly.py candlestick chart?
Asked Answered
N

5

13

I am creating a candlestick plot using plotly.py. I would like to have a horizontal split and place the candlestick data in the top split and some data curves in the bottom bottom split. I do not need panning and zooming and that lower section of the candlestick chart with the zoom/pan controls is getting in my way.

enter image description here

Navarrete answered 3/1, 2018 at 17:20 Comment(0)
B
23

To disable zoom and panning you need to set: layout.xaxis.fixedrange = true and layout.yaxis.fixedrange = true.

To hide the controls you need to set displayModeBar = false.

In Python this would for example look like this:

dcc.Graph(
    id='my-id',
    config={'displayModeBar': False},
   'layout': go.Layout(
       xaxis={'title': 'x-axis','fixedrange':True},
       yaxis={'title': 'y-axis','fixedrange':True})
)
Bodily answered 21/10, 2019 at 21:59 Comment(2)
This hides the controls at the top, not what is being asked.Nealey
this is useful for heatmapsDanicadanice
H
3

I disabled it with layout.xaxis.rangeslider.visible = false

Hyacinthie answered 11/2, 2018 at 11:29 Comment(1)
Well done! This is really useful specially if you want to save as imageGurias
E
1

It is possible to disable individual buttons from the bar.

See the Plotly Python documentation on the configuration object: https://plotly.com/python/configuration-options/#removing-modebar-buttons

example code:
fig.show(config={ 'modeBarButtonsToRemove': ['zoom', 'pan'] })

Emanuel answered 18/2, 2022 at 0:58 Comment(0)
I
1

do that ont the figure before show():

fig.update_xaxes(rangeslider_visible=False)

fig.show()

Inedible answered 20/4 at 21:1 Comment(2)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Recurrent
Worked for me. I just added this line fig.update_xaxes(rangeslider_visible=False)Heelpost
P
0

If you save the file using the control save method, I think that it disables the zoom/pan function. Around October, I had a similar issue, and when I simply saved the chart, the zoom/pan function went away. Let me know if that works.

Pectin answered 3/1, 2018 at 17:24 Comment(1)
Thanks. But that kind of defies the functionality of the chart as it becomes an image and is not interactive anymore.Navarrete

© 2022 - 2024 — McMap. All rights reserved.