I'm struggling because while I want to show the interrelationship of correlation between my fields, I realize that trying to plot nodes in terms of distance away from each other based on correlation will lead to impossibilities such as a case where A and B are 1 unit apart, B and C are 1 unit apart, but C and A are say, 5 units apart, there is no way to represent this on a 2 dimensional plane.
I simply want to create a visualization that generally clusters things with high correlation together, and moves things that are anti-correlated apart. So far, the closest I've gotten is using python networkx:
import pandas as pd import numpy as np import networkx as nx import matplotlib.pyplot as plt G = nx.Graph() for ii in range(len(links_filtered)): a = data['var1'][ii] b = data['var2'][ii] c = data['value'][ii] G.add_edge(a,b,length=c,weight=c) elarge = [(u,v) for (u,v,d) in G.edges(data=True) if d['weight']>0] esmall = [(u,v) for (u,v,d) in G.edges(data=True) if d['weight']<=0] pos = nx.spring_layout(G,k=.2,iterations=10000) nx.draw_networkx_nodes(G,pos,node_color='orange',node_size=400) nx.draw_networkx_edges(G,pos,edgelist=elarge,edge_color='blue') nx.draw_networkx_edges(G,pos,edgelist=esmall,edge_color='red',alpha=0.5,style='dashed') # nx.draw_networkx_labels(G,pos,font_size=8,) for k,v in pos.iteritems(): x,y = pos[k] plt.text(x,y,k,bbox=dict(facecolor='white',alpha=0.8),horizontalalignment='center',verticalalignment='baseline',fontsize=8,color='black')
However, the result is generally ugly, and doesn't actually ensure that clusters that are not correlated are not in close proximity, since it is only drawing edges, not actually calcing a distance between nodes.