title: Plotly: How to change legend for a go.pie chart without changing data source?
body: <p>I am practising building a Pie Chart in Plotly Express using Python. <br>
  So, this is the Pie Chart that I made; <br>
  <a href="https://i.stack.imgur.com/inGA6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/inGA6.png" alt="enter image description here" /></a></p>
  <p>This chart was build from a file with two columns called<br></p>
  <ol>
  <li><code>gender</code> with values of <code>[0, 1, 2]</code> <br></li>
  <li><code>count_genders</code> with values of <code>[total_count_0, total_count_1, total_count_2]</code> <br></li>
  </ol>
  <p>I am planning to add some description to those values; for instance<br></p>
  <ul>
  <li><code>0 - female</code><br></li>
  <li><code>1 - male</code><br></li>
  <li><code>2 - undefined</code><br></li>
  </ul>
  <p>This is where I am currently stuck. <br>
  If I remember correctly if you want to change a label in the legend (at least in Choropleth map), you could manipulate the <code>ticks</code> located in <code>colorscale</code> bar. By manipulating them, you could rename the label about the data. Thus I am wondering if you could do the same in Pie chart? <br></p>
  <p>My current code for this graph:</p>
  <pre><code>import pandas as pd
  import plotly.express as px
              
  '''
  Pandas DataFrame:
  '''
  users_genders = pd.DataFrame({'gender': {0: 0, 1: 1, 2: 2},
                 'count_genders': {0: 802420, 1: 246049, 2: 106}})
  
  ''' Pie Chart Viz '''
  gender_distribution = px.pie(users_genders,
                               values='count_genders',
                               names='gender',
                               color_discrete_map={'0': 'blue',
                                                   '1': 'red',
                                                   '2': 'green'},
                               title='Gender Distribution &lt;br&gt;'
                                     'between 2006-02-16 to 2014-02-20',
                               hole=0.35)
  gender_distribution.update_traces(textposition='outside',
                                    textinfo='percent+label',
                                    marker=dict(line=dict(color='#000000',
                                                          width=4)),
                                    pull=[0.05, 0, 0.03],
                                    opacity=0.9,
                                    # rotation=180
                                    )
  gender_distribution.update_layout(legend=dict({'traceorder': 'normal'}
                                                # ticks='inside',
                                                # tickvals=[0, 1, 2],
                                                # ticktext=[&quot;0 - Female&quot;,
                                                #           &quot;1 - Male&quot;,
                                                #           &quot;2 - Undefined&quot;],
                                                # dtick=3
                                                ),
                                     legend_title_text='User Genders')
  gender_distribution.show()
  </code></pre>
  <p>I tried to add the <code>ticks</code> in the <code>update_layout</code> to no avail. It returns an error message about incorrect parameters. Would someone kindly help me fix this issue?</p>
  <p><strong>edit 1</strong>: In case I wasn't clear, I wanted to know if it's possible to modify the values displayed in the legend without changing the original values within the file. Many thanks for your time for those who are already kind enough to help me fix this issue! <br></p>
  <p><strong>edit 2</strong>: Add the imports and other prior details of the code, removing the Dropbox link.<br></p>