# Help with a Heatmap Graph

**URL:** <https://community.plotly.com/t/help-with-a-heatmap-graph/70056>\
**Category:** Plotly R, MATLAB, Julia, Net\
**Created:** [November 19, 2022, 5:12am UTC](https://community.plotly.com/t/help-with-a-heatmap-graph/70056 "2022-11-19T05:12:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fnnepali](https://avatars.discourse-cdn.com/v4/letter/f/dc4da7/32.png) [@fnnepali](https://community.plotly.com/u/fnnepali)\
**Post date:** [November 19, 2022, 5:12am UTC](https://community.plotly.com/t/help-with-a-heatmap-graph/70056/1 "2022-11-19T05:12:23Z")

</div>

![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/e/8/e866ebee6a3d4132c8b28d7ada1ad03350f602d5.jpeg)

Can someone help me with graph like the one attached ? Any pointers that I can use to create this kind of graph. My data is each row in the graph is a column in the dataframe with its own category. I would like to create something like the attached and also create a legend for each category.

Thank you

---

<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:** [November 20, 2022, 4:35pm UTC](https://community.plotly.com/t/help-with-a-heatmap-graph/70056/2 "2022-11-20T16:35:44Z")

</div>

Hi @fnnepali , maybe a scatterplot? I am aware that I am responding in Python, but maybe it gives you some ideas. Adjusting the axis ranges, figure dimensions and marker size may be a bit cumbersome, though. You will also have to find a solution for coloring each marker to your needs.

```python
import plotly.graph_objects as go
import numpy as np

cat_num = 5

# set number of types
type_num = 20

# create data
categories = []
for i in range(1, cat_num + 1):
    categories.extend([f'category_{i}'] * type_num)
types = [i for i in range(type_num)] * cat_num    
values = np.random.randint(1, 40, cat_num * type_num)    

# create figure
fig = go.Figure(go.Scatter(y=categories, x=types, mode='markers'))
fig.update_traces(marker_symbol='square', marker_size=60, marker_color=values, marker_line_color='black', marker_line_width=3)
fig.update_layout(height=600, width=1600)

```

Which creates:

 ![newplot(16)](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/5/b/5b2a50afc59d8b43a809899b614a1e641ccd5866.png)  
mrep scatter git

---

<div class="post-metadata">

**Author:** ![fnnepali](https://avatars.discourse-cdn.com/v4/letter/f/dc4da7/32.png) [@fnnepali](https://community.plotly.com/u/fnnepali)\
**Post date:** [November 23, 2022, 9:53pm UTC](https://community.plotly.com/t/help-with-a-heatmap-graph/70056/3 "2022-11-23T21:53:29Z")

</div>

Thank you for the python code. I was more looking for Plotly R but I will explore using this as starting point.
