# Trying to display all y-axis names in scatter chart even without data

**URL:** https://community.plotly.com/t/trying-to-display-all-y-axis-names-in-scatter-chart-even-without-data/72079
**Category:** 📊 Plotly Python
**Created:** [January 30, 2023, 7:14am UTC](https://community.plotly.com/t/trying-to-display-all-y-axis-names-in-scatter-chart-even-without-data/72079 "2023-01-30T07:14:21Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![AIMPED](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/aimped/32/21758_2.png) [@AIMPED](https://community.plotly.com/u/AIMPED)
#### Post date: [January 30, 2023, 10:31am UTC](https://community.plotly.com/t/trying-to-display-all-y-axis-names-in-scatter-chart-even-without-data/72079/3 "2023-01-30T10:31:36Z")

</div>

Hi @ShreyanshG,

while @AbdelAnlah has a valid point, you could map your names to integers, plot these integers on the y-axis over the x-axis and use custom ticks to use the actual names. You could also map a color to each name.

```python
import pandas as pd
import random
import plotly.express as px

random.seed(42)
days = 31

# create data
week = pd.date_range('01/01/2022', periods=days, freq='D')

# all names
all_names = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')

# current names in period
current_names = list('EFGHIJKXRQD')
current_names = [random.choice(current_names) for _ in range(days)]

# name mapping name --> int
name_map_dict = {n: i for n, i in zip(all_names, range(len(all_names)))}

# color mapping name -- color string
color_map_dict = {n: c for n, c in zip(all_names, px.colors.qualitative.Alphabet)}

# create DataFrame
df = pd.DataFrame({'date': week, 'names': current_names})

# add columns with mapped entities
df['name_mapped_to_int'] = df.names.apply(lambda x: name_map_dict[x])
df['name_mapped_to_color'] = df.names.apply(lambda x: color_map_dict[x])

# create figure
fig = px.scatter(df, x='date', y='name_mapped_to_int')

# custom range and ticks
fig.update_layout({
    'yaxis': {
        'range': [0, len(all_names)],
        'tickmode': 'array',
        'tickvals': [*range(len(all_names))],
        'ticktext': all_names
    },
    'height': 600,
    'width': 600,
    'template': 'plotly_dark'
})

fig.update_traces(marker_color=df.name_mapped_to_color)

```

creates:

 ![newplot (47)](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/f/7/f7dff5e8163dfe6a80602a7fe0d85389ecb10e1e.png)

---

_[View the full topic](https://community.plotly.com/t/trying-to-display-all-y-axis-names-in-scatter-chart-even-without-data/72079)._
