Here's a solution in Python. It uses pandas to load the data from an excel file, NetworkX to create a network from that data, and gravis to visualize the network. Disclaimer: I'm the author of gravis, an open source Python package for network visualization.
import gravis as gv
import networkx as nx
import pandas as pd
df = pd.read_excel('data.xlsx')
x_scale = 100
y_scale = 60
colors = ['blue', 'orange', 'gray', '#ffcc55', 'lightblue', 'green', '#dddd00']
dg = nx.DiGraph()
entry_to_color = dict()
entry_counter = 0
dg.graph['node_shape'] = 'rectangle'
for i, col_name in enumerate(df.columns):
col = df[col_name]
for j, entry in enumerate(col):
node = str(i) + str(entry)
if entry not in entry_to_color:
entry_to_color[entry] = colors[entry_counter]
entry_counter += 1
dg.add_node(node, name=entry, x=i*x_scale, y=j*y_scale, i=i)
for i, n_name in enumerate(dg.nodes):
node = dg.nodes[n_name]
color = entry_to_color[node['name']]
node['color'] = color
node['label_color'] = color
for n1_name in dg.nodes:
for n2_name in dg.nodes:
n1 = dg.nodes[n1_name]
n2 = dg.nodes[n2_name]
if n1 != n2 and n1['name'] == n2['name'] and n2['i'] == n1['i']+1:
dg.add_edge(n1_name, n2_name, color=n1['color'])
gv.d3(dg, node_label_data_source='name')
Here's the output if you run that code inside a Jupyter notebook, although it could also be done in the normal Python interpreter:
