0

I'm plotting a list of tuples, which contains the x and y coordinates of each point.

The problem is : I am able to plot the points individually or connect them sequentially. However, I can't really find a way to let each data point connect to adjacent points. In other words, I want to make a net-like figure with each data point being a node.

Accurately speaking, I wanted to plot dots that connect to other adjacent dots.

I'm not really sure what to add or edit this piece of code.

 points = []  # A container to place my coordinates

     """
     self.net is a 10*10*2 ndarray that describes the x and y values of 
     each weight. There is a total of 100 weights.
     (I'm doing a SOM by the way)
     """

     for m in range(self.network_dimensions[0]):
         for n in range(self.network_dimensions[1]):
             points.append((self.net[m][n][0], self.net[m][n][1]))
     plt.plot(*zip(*points), 'bo-')
     plt.show()
     # This plot is shown as Result_2
     # If I plot each point individually, I get Result_1

Here are some current results:

Result_1: https://i.stack.imgur.com/VaGs2.jpg

Result_2: https://i.stack.imgur.com/JhO0i.jpg

KHT
  • 13
  • 6
  • 1
    Could be what you are looking for: [Connect all 2D Points from NumPy 2D Arrays as a triangular meshgrid](https://stackoverflow.com/questions/24555132/connect-all-2d-points-from-numpy-2d-arrays-as-a-triangular-meshgrid) – Georgy Apr 05 '19 at 14:19
  • 1
    Or maybe this: [How can I plot 2d FEM results using matplotlib?](https://stackoverflow.com/questions/52202014/how-can-i-plot-2d-fem-results-using-matplotlib) – Georgy Apr 05 '19 at 14:21
  • do you mind sharing a picture of what you want the plot to look like? – mostafazh Apr 05 '19 at 18:50
  • Unless the question is edited to show in how far those two links above would not help, I would be inclined to close as duplicate of them. – ImportanceOfBeingErnest Apr 05 '19 at 22:00
  • I'm looking into it. I'll post an update later on. Tks – KHT Apr 06 '19 at 04:53
  • @Georgy The second link does look very similar. But I was wondering if there's a way of finding the elements the tool required quickly? Sorry if that is a dumb question. The first link does provide insight but I'm more inclined to make a quadrilateral mesh instead of a triangular one since my initial-weight mesh is in more of a square-shaped manner. – KHT Apr 06 '19 at 05:29
  • @mostafazh I'll draw a figure and post it as an edit later. Tks – KHT Apr 06 '19 at 05:30

0 Answers0