I’ve created a simple Plotly chart in Python, and I can change the Modebar options quite easily. However, when I’m trying to publish the same chart to Chart-Studio, not all the Modebar configurations are working. Any ideas?
Here is the code:
import pandas as pd
import numpy as np
import plotly.graph_objects as go
df = pd.DataFrame({'a':[2,4,6,8,10],'b':[3,6,9,12,15]})
fig = go.Figure()
fig.add_trace(go.Scatter(x=df.index, y=df['a'], mode='lines', name='a', line=dict(color='dodgerblue', dash='solid')))
fig.add_trace(go.Scatter(x=df.index, y=df['b'], mode='lines', name='b', line=dict(color='lightsalmon', dash='dash')))
fig.update_layout(
title='a and b',
autosize=False,
width=500,
height=500,
newshape=dict(line_color='mediumaquamarine', line_width=2, opacity=1)
)
config = {
'modeBarButtonsToAdd' : ['drawline', 'drawopenpath', 'drawrect', 'eraseshape'],
'displaylogo' : False
}
fig.show(config=config)
The figure that appears has the logo removed and the additional buttons on the modebar showing as it should…
However, if I try to publish this to Chart-Studio:
import chart_studio.plotly as py
import chart_studio
chart_studio.tools.set_credentials_file(username='xxxxx', api_key='#####')
py.plot(fig, filename='a and b', auto_open=False, config=config)
This doesn’t work. Note, the logo doesn’t appear so I thought that part was working, but actually if I turn displaylogo=True
then it doesn’t show the logo either. So it appears none of the config arguments are working.
I’m not sure if this is exactly the way to update config
in Chart-Studio but I can’t find any documentation for it, I tried this based on this old post:
Adding config modes to Plotly.Py offline - modebar
I also tried saving the fig file with the config argument and publishing that but that gives an error. What I’ve tried here doesn’t give an error but it doesn’t do anything.
Thanks