Splom layout updating

Hi @naveace welcome to the community and thanks for the MRP.

When I do not know how to alter specific items of a chart, I usually convert the figure into a dictionary with fig.to_dict() and inspect it. In general, plotly uses a nested structure like a dictionary or json.

So doing that with the px.scatter_matrix shows, that the label of the pop hides here:

fig.data[0]['dimensions'][0]['label']

You can change this to whatever you like via
fig.data[0]['dimensions'][0]['label']='Population'

Full code:

import plotly.express as px
df = px.data.gapminder().query("year==2007")
fig = px.scatter_matrix(df, dimensions=["pop", "lifeExp", "gdpPercap"],
                        color="continent", title="Gapminder 2007")

fig.data[0]['dimensions'][0]['label']='Population'
fig.show()

creates:
newplot (11)

There might be other ways to do this and maybe even built in functions, but my experience with these type of “special figures” is somewhat limited.

2 Likes