How to set the format of the marginal graph in dash plotly?

Question:

I have a scatterplot with a marginal_y subgraph made with:

fig = px.scatter(df_filtrada, 
                 x=df_filtrada.index, 
                 y=pto, 
                 marginal_y = "violin")

When I update some properties of the main graph such as the background color it affects the background of the marginal subgraph as well such as the background color:

fig.layout.paper_bgcolor='rgba(0,0,0,0)'
fig.layout.plot_bgcolor='rgba(0,0,0,0)'

However, I haven’t managed to remove the grid of the marginal axis:
enter image description here

How can I format the marginal_y chart properties such as the show_grid property? And can other properties be adjusted as well such as the title?

Asked By: Adrian Fischer

||

Answers:

Plotly handles marginal_x, marginal_y axis as subplots.

Thus their layout can be adjusted by explicitly specifying the subplot nr to be updated. In this case the marginal axis is in row=1, col=2:

fig.update_yaxes(showgrid=False, row=1, col=2)
fig.update_yaxes(zeroline=False, row=1, col=2)

Credit to mnikley, r-beginners for providing the answer in the comments.

Answered By: Adrian Fischer