Remove default white graph background?

One of the graphs in my dash application is rendered upon an button click event from the callback.

I’d like to remove the default white background of the graph when the page is loaded. It kinda looks odd for my layout. Is this possible?

Screen Shot 2020-12-12 at 11.49.16 AM

I have already tried the following with no success.


layout=go.Layout(

                annotations=[{'text': str(score) + "%", 'x':0.5, 'y':0.5, 'font_size':35, 'showarrow':False}],
                paper_bgcolor = 'rgba(0,0,0,0)',
                plot_bgcolor = 'rgba(0,0,0,0)',
                showlegend=False
            )

Hi keval,

You can set the dcc.graph styles with: style={‘display’:‘none’} and then when the callback is called just change it to style={‘display’:‘block’} or style={‘display’:‘inline’}

1 Like

Hello! Can you explain with a code how to do ?)

An Easy way is using an empty dcc.Div(id=‘mygraph’) where you want to show the graph.
In the callback you can use no_update to avoid the execution of the callback until the button is clicked.
Then return the graph figure to the id ‘mygraph’

Thanks, I eventually solved the problem this way)

1 Like