在 Plotly 中更改图表颜色,Python

Change graph color in Plotly, Python

就像我们可以使用 color 属性更改 matplotlib 中绘制图形的颜色一样,有什么方法可以更改 plotly[=16= 中图形的颜色]?.

import plotly.graph_objects as go
import numpy as np

x = np.linspace(-np.pi, np.pi)
y = np.cos(x)

# this will create a blue line
fig = go.Figure([
    go.Scatter(x=x, y=y)
])
# to modify the figure after it has been created,
# explore fig.data and target the appropriate attribute
fig.data[0].line.color="red"
fig