Announcing Dash Bio 1.0.0 🎉 : a one-stop-shop for bioinformatics and drug development visualizations.

Secondary Y Axis while changing colorscale

Hi everyone! Upon executing this code, the following graph appears:

import pandas as pd, numpy as np
import as px
from plotly.subplots import make_subplots

artists = pd.read_pickle('pickle/artists.pkl')
songs = pd.read_pickle('pickle/songs.pkl')

fig = make_subplots(specs=[[{"secondary_y": True}]])

year = artists.breakthrough_date.apply(lambda x: x.year)
x = [i for i in np.sort(year.unique()) if i not in [1958, 1959, 2020]]
y = [year.value_counts()[i] for i in x]
color = [math.floor(i/10)*10 for i in x]
bar = = x, y = y, color = color)

year = songs.debut_date.apply(lambda x: x.year)
y2 = [songs.debut_weeks[year == i].median() for i in x]
line = go.Scatter(x = x, 
                  y = y2, 
                  line = dict(color = 'orange', shape = 'linear', width= 10))

fig.add_trace([0], secondary_y = False)
fig.add_trace(line, secondary_y = True)
fig.update_layout(template = 'simple_white', coloraxis_showscale = False)
st.plotly_chart(fig, config = config)

my question is, how do I change the colorscale from Veridis to another one, say, Inferno? Having some difficulty determining which property to update in order to achieve this.

Please let me know how you would go about updating the colorscale of the bar portion of this chart, thanks!


When you want to change some data or layout settings of a Figure, generated by plotly. expresss, just print

print( or print([k]), for some integer k ranging from 0 to the number of fig traces,
as well as print(fig.layout) to see how an attribute can be updated.

In your case it is fig.update_layout(coloraxis_colorscale='new_colorscale_name')