FFXX
FFXX

Reputation: 115

AttributeError: 'LineCollection' object has no attribute 'do_3d_projection'

Given a 3D data ,I want to visualise a grid SOM graph while the data is shown on 3D plane but I get the following error: AttributeError: 'LineCollection' object has no attribute 'do_3d_projection' and just a white screen will open up without any graph or 3d plane

here is the what I mean by visualising a grid SOM with my data: enter image description here

and here is the code:

import numpy as np
import matplotlib.pyplot as plt
import networkx as nx
import numpy.random as rnd

#Grid SOM
def initGridSOM(matX, kx, ky):
   G = nx.generators.lattice.grid_2d_graph(kx, ky)
   G = nx.convert_node_labels_to_integers(G)
   m, n = matX.shape
   smpl = rnd.choice(n, kx*ky, replace=False)
   for i, v in enumerate(G):
     G.nodes[v]['w'] = matX[:,smpl[i]]
   return G

if __name__=="__main__":
   fig = plt.figure()
   ax = fig.add_subplot(111, projection='3d')
   matX = np.loadtxt('q3dm1-path1.csv', delimiter=',', unpack=True)#array with 3*1327
   x,y,z=matX
   ax.scatter(x,y,z,c='r',marker='o')
   ax.set_xlabel('x axis')
   ax.set_ylabel('y axis')
   ax.set_zlabel('z axis')
   SOM1=initGridSOM(matX,10,10)
   nx.draw(SOM1,
           node_color='gray',
           with_labels=False,
           node_size=50)
   plt.show()

can anyone tell me what is wrong with my code that I get such an error and I can not render the data with the graph? here is the error: enter image description here

Upvotes: 2

Views: 2088

Answers (0)

Related Questions