Help with a Heatmap Graph

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

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.

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:


mrep scatter git

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