How to change graph background color in plotly go.Scatter?

i’m looking for a way to change graph background color in plotly go.Scatter ?

thanks

import plotly.graph_objects as go
import numpy as np

N = 1000

t = np.linspace(0, 10, 100)

y = np.sin(t)

fig = go.Figure(data=go.Scatter(x=t, y=y, mode=β€˜markers’))

# Changing the background color

fig.update_layout(
plot_bgcolor=β€˜#899866’) # change here
)

fig.show()

2 Likes

thanks that works, btw do you know how to set different colors for plotted data ? in case of graph object scatter plot

what is the current best practice for doing this with scatter_3d?

ah, found it (for scatter3d)

        "scene": {
            # "plot_bgcolor": plot_color    doesnt work
            "xaxis": {"backgroundcolor": plot_color},
            "yaxis": {"backgroundcolor": plot_color},
            "zaxis": {"backgroundcolor": plot_color}
        }
1 Like