Hi Dashers -
I have an app that contains several graphs that have large legends and include custom updatemenu buttons.
They look great in the app but when I attempt to download them as .png files using the camera button in the modebar, the legend tends to cut into the graph and my custom buttons block some of the axis.
Here’s a screenshot of the plot as it appears in the browser in my app:
Here’s what the .png file looks like when downloaded using the modebar button:
Here’s some pseudo code for how I’m creating the graph:
# config options to apply to all graphs
plotConfig = {'showLink': False, 'modeBarButtonsToRemove': ['sendDataToCloud'], 'displaylogo': False}
legendConfig = dict(orientation='h', x=0, y=1.1)
# app layout
app.layout = html.Div([
other components........,
dcc.Graph(id='adoption-graph', config=plotConfig)]
)
# module to create the graph in question using some data set that i'm not showing here
@app.callback(
Output('adoption-graph', 'figure'),
[Input('dataset', 'children')])
def make_adoption_graph(dataset):
allStats = DataFrame(dataset)
# make traces for the plot
traces = [scatter1, scatter2, scatter3]
updatemenus = list([
dict(active=3, showactive=True, type='buttons', xanchor='left', x=-.15,
buttons=list([
dict(label='Day', method='update', args=[{'visible': ([False]*12 + [True]*4)}]),
dict(label='Week', method='update', args=[{'visible': ([False]*8 + [True]*4 + [False]*4)}]),
dict(label='Month', method='update', args=[{'visible': ([False]*4 + [True]*4 + [False]*8)}]),
dict(label='Cumulative', method='update', args=[{'visible': ([True]*4 + [False]*12)}])
]))
])
layout = dict(title='Adoption Over Time',
xaxis=dict(rangeselector=dict(x=.8, y=1, buttons=list([
dict(count=1, label='1mo', step='month', stepmode='backward'),
dict(count=6, label='6mo', step='month', stepmode='backward'),
dict(step='all')])),type='date'),
yaxis=dict(tickformat=tickForm, hoverformat=hForm),
legend=legendConfig,
updatemenus=updatemenus)
return dict(data=traces, layout=layout)
Is there a way to tell plotly how to format the png so that it looks like the graph in my browser?
Thanks!