title: Plotly: How to specify colors for a group using go.Bar?
body: <p>How to use <code>plotly.graph_objs</code> to plot pandas data in a similar way to <code>plotly.express</code> - specifically to color various data types?</p>
  
  <p>The plotly express functionality to group data types based on a value in a pandas column is really useful. Unfortunately I can't use express in my system (as I need to send the graph object to <a href="https://github.com/plotly/orca" rel="nofollow noreferrer">orca</a>)</p>
  
  <p>I'm able to get the same functionality by specifically mapping <code>Type</code> to colours (<code>full_plot</code> in the example below), however I have types A-Z, is there a better way of mapping each possible <code>Type</code> in the dataframe to a color?</p>
  
  <pre class="lang-py prettyprint-override"><code>import pandas as pd
  import plotly.express as px
  import plotly.graph_objs as go
  
  d = {'Scenario': [1, 2, 3, 1, 2,3],
       'Type': ["A", "A", "A", "B", "B", "B"],
       'VAL_1': [100, 200, 300, 400 , 500, 600],
       'VAL_2': [1000, 2000, 3000, 4000, 5000, 6000]}
  df = pd.DataFrame(data=d)
  
  
  def quick_plot(df):
  
      fig = px.bar(df, y='VAL_1',  x='Scenario',  color="Type", barmode='group')
      fig['layout'].update(title = "PX Plot",
                       width = 600, height = 400,
                       xaxis = dict(showgrid=False))
      fig.show()
  
  
  def full_plot(df):
  
      colors = {'A': 'blue',
            'B': 'red'}
      s0=df.query('Type=="A"')
      s1=df.query('Type=="B"')
  
      fig = go.Figure()
      fig.add_trace(go.Bar(
          name='A',
           y=s0['VAL_1'],x=s0['Scenario'], marker={'color': colors['A']}))
      fig.add_trace(go.Bar(
          name='B',
           y=s1['VAL_1'],x=s1['Scenario'], marker={'color': colors['B']}))
  
      fig['layout'].update(title = "Full Plot",
                       width = 600, height = 400)
  
      fig.update_layout(barmode='group')
      fig.show()
  
  quick_plot(df)
  full_plot(df)
  </code></pre>