Why does my graph plot look incorrect?
Why does my graph plot look incorrect?
Hello,
I have a question - I have differences calculated between game genres. The difference is a positive float number, the bigger the number, the greater the difference there is between the two genres.
I want to visualise differences and I have the following code:
import json import networkx as nx import matplotlib.pyplot as plt with open('genres_weights.json', 'r') as file: data = json.load(file) G = nx.Graph() max_diff = max(item['difference'] for item in data) if data else 1.0 for item in data: node1, node2 = item['weightsPair'] difference = item['difference'] weight = item['difference'] + 0.25 G.add_edge(node1, node2, weight=weight, original_diff=difference) plt.figure(figsize=(40, 20)) pos = nx.kamada_kawai_layout(G, weight='weight') nx.draw_networkx_nodes(G, pos, node_size=2000, node_color='#2b83ba', alpha=0.9) nx.draw_networkx_labels(G, pos, font_size=7, font_family='sans-serif') plt.show()
that gives the following result for my data:
A lot of things look great, and overall graph represents data correctly (I guess). But there is the thing - in the bottom left part of the graph there are two bubbles: "immersive sim" and "rhythm". Those two genres appear to be very similar (as some other pairs of games that are very similar and have a very low number for difference), but in reality, they are not - they have a difference of 9, which is a lot (the maximum difference between genres is around 14), so I expect them to be on the different side of the graph and not nearly together.
I'm not sure where the problem is. Can someone please help me?