# Set Customize Discrete Color to Plotly Graph Objects

**URL:** <https://community.plotly.com/t/set-customize-discrete-color-to-plotly-graph-objects/51865>\
**Category:** 📊 Plotly Python\
**Created:** [April 9, 2021, 7:37am UTC](https://community.plotly.com/t/set-customize-discrete-color-to-plotly-graph-objects/51865 "2021-04-09T07:37:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![c45513](https://avatars.discourse-cdn.com/v4/letter/c/85e7bf/32.png) [@c45513](https://community.plotly.com/u/c45513)\
**Post date:** [April 9, 2021, 7:37am UTC](https://community.plotly.com/t/set-customize-discrete-color-to-plotly-graph-objects/51865/1 "2021-04-09T07:37:41Z")

</div>

Hi everyone, I’m new to plotly, I have two different plots below (go.Pie & go.Bar) and I like to assign a color to each type (a - g) label as shown in the color\_discrete\_map. How do I include them in the codes for go.pie & go.bar? Thanks you very much!

![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/f/f1de06e0df82b39521500affa34fb6b19f94df5c.png)

```auto
    color_discrete_map = {'a':'rgb(42,9,4)', 
                              'b':'rgb(111,203,209)',
                              'c':'rgb(55,165,172),',
                              'd':'rgb(29,127,136)',
                              'e':'rgb(2,84,92)',
                              'f':'rgb(4,37,42)',
                              'g':'rgb(7,97,42)'
}
    
    unit_mix_pie.add_trace(go.Pie(labels=df.index, values=df['type']), row=1, col=1)

unit_mix_bar.add_trace(go.Bar(x=df.index, y=round(df['type'],0), marker=dict(
        color=px.colors.qualitative.Pastel2, color_discrete_map=color_discrete_map,
        line=dict(color='#000000', width=2)
    )), row=1, col=1)

```
