0

I am trying to get rid of the gridlines in all the subplots of the scatter_matrix plot. I have set the showgrid parameter to False for the x-axis and y-axis, but the majority of the subplots do have the gridlines still being presented. How do I resolve this issue?

This is my code:

import plotly.express as px
df = px.data.iris()
fig = px.scatter_matrix(df,
    dimensions=["sepal_width", "sepal_length", "petal_width", "petal_length"],
    color="species")
fig.for_each_xaxis(lambda x: x.update(showgrid=False))
fig.for_each_yaxis(lambda x: x.update(showgrid=False))
fig.show()

This is the image: ploy

1 Answers1

0
  • the axes are not already in the layout hence reason the approach you have used does not work. Also update_xaxes() and update_yaxes() do not work
  • using a dict comprehension to explicitly set for 10 x&y axes does work
fig.update_layout(
    {
        f"{ax}axis{n+1 if n>0 else ''}": {"showgrid": False}
        for n, ax in itertools.product(range(10), list("xy"))
    }
)

enter image description here

Rob Raymond
  • 29,118
  • 3
  • 14
  • 30