✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

Color specific bar (discrete or continuous) like plotly express based on X axis value

import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import plotly.graph_objs as go
import pandas as pd
import time
import plotly.express as px
import numpy as np
pd.set_option('display.width', 400)
pd.set_option('display.max_columns', 50)

df1 = pd.read_csv(r"E:\\OI\\test_mar_2020.csv")
df1['Date'] = pd.to_datetime(df1['Date'])
df1['Monthly_Exp_End'] = pd.to_datetime(df1['Monthly_Exp_End'])
df1['Monthly_Exp_Start'] = pd.to_datetime(df1['Monthly_Exp_Start'])
df1['Monthly_exp_end_ind'] = np.where(df1['Monthly_Exp_End']==df1['Date'] , True, False)
df = df1[df1['Year'].isin([2020])]

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

party_data = []
for client in df['Client_Type'].unique():
    party_data.append({'label': client, 'value': client})

    # fig = go.Figure()
    # fig.add_trace(go.Bar(x=[1, 2, 3], y=[1, 3, 2]))
    # fig.add_trace(go.Scatter(x=[1, 2, 3], y=[4, 2, 1], mode="lines"))

app.layout = html.Div([
                  html.Div([
             dcc.Dropdown(id='client-picker',options=party_data,value= 'Test1' )]),
             dcc.Graph(id='graph')
                      ])

@app.callback(Output('graph', 'figure'), [Input('client-picker', 'value')])
def update_figure(client_picker_name):
   df_new = df[df.Client_Type == client_picker_name]
# I want to add a color argument lile plotly.express--- fig = px.scatter(df, x=“sepal_width”, #y=“sepal_length”, color=“species”) into below trace1 
   trace1 = go.Bar(x=df_new.Date, y=df_new.colA)
   trace2 = go.Bar(x=df_new.Date, y=df_new.colB)
   trace3 = go.Scatter(x=df_new.Date, y=df_new.colC, mode='lines+markers', yaxis='y2')

   return {
        'data' : [trace1,trace2,trace3]
     }


if __name__ == '__main__':
    app.run_server(debug=True,port = 8080)