Iβm playing around with using plotly as my default plotting package for scientific computing. Mostly I work in Jupyter notebooks, but I have a default colorscheme with dark backgrounds. In matplotlib it is possible to change the default colors of the plots to match almost every layout and I would really like to replicate this in plotly.
Is there any way to change the default colors of offline plots in Jupyter notebooks?
I wrote a small code example which I hope covers you needs:
import pandas as pd
import plotly.graph_objs as go
import plotly.io as pio
from plotly.offline import iplot, init_notebook_mode
init_notebook_mode(connected=True)
# make a fig and use the color layout as template
colorlist = ['rgb(0,60, {:d})'.format(40*i) for i in range(10)]
fig = go.Figure(layout = dict(colorway = colorlist))
templated_fig = pio.to_templated(fig)
pio.templates['my_template'] = templated_fig.layout.template
pio.templates.default = 'my_template'
# plot a new figure
x = np.linspace(0,2*np.pi,100)
y = np.sin(x)
newfig = go.Figure()
for i in range (10):
newfig.add_scatter(x=x,y=y*i/10)
iplot(newfig)