You can try this to draw the lines between the different points.
The difficulty is to select in your array the points that match together. import numpy as np n = 30 array = flatten([[a*vector([float(sqrt(3))/2,0.5]) + b*vector([float(sqrt(3))/2,-0.5]) for a in (0..n)] for b in (0..n)] + [[a*vector([float(sqrt(3))/2,0.5]) + b*vector([float(sqrt(3))/2,-0.5]) + vector([-1/float(sqrt(2)),0]) for a in (0..n)] for b in (0..n)]) arrayP = np.asarray(array) g = Graphics() i = 0 while i < n**2: pointO = arrayP[i] pointA = arrayP[i + (n+1)**2] pointB = arrayP[i + (n+1)**2 +1] pointC = arrayP[i + (n+1)**2 + n+1] line1 = line([pointO,pointA],aspect_ratio=1) line2 = line([pointO,pointB],aspect_ratio=1) line3 = line([pointO,pointC],aspect_ratio=1) if i%(n+1) == n: #to avoid long return lines between points g += line1 + line3 else: g += line1 + line2 +line3 i +=1 g Le vendredi 17 mai 2019 05:35:54 UTC+2, saad khalid a écrit : > > Hi everyone: > > I'm trying to using Sage's plot functionality to plot the honeycomb > lattice: > > https://sites.google.com/site/makingplots4scipurposes/_/rsrc/1456789513003/gnuplot-samples-of-2d-lattices/honeycomb.png > > Plotting the honeycomb lattice is slightly different from plotting a > simple (like a square) lattice, as each site is technically two points, > with a basis vector pointing from one point to the other within a single > site. So you take your two lattice vectors and start from some point and > generate all possible points from those lattice vectors. Then you go back > to your starting point, shift by the basis vector, and then generate all > possible points from there using the lattice vector, and then you add these > two sets of points together to get the honeycomb lattice. I've figured out > how to do it using points at the corner of each hexagon, like this: > list_plot(flatten([[a*vector([sqrt(3)/2,1/2]) + b*vector([sqrt(3)/2,-1/2]) > for a in (0..30)] for b in (0..30)] + [[a*vector([sqrt(3)/2,1/2]) + b* > vector([sqrt(3)/2,-1/2]) + vector([-1/sqrt(2),0]) for a in (0..30)] for b > in (0..30)])) > > However, I was hoping to do this with lines outlining the hexagons as > shown in the linked image. Would anyone know of a way to do this? Thanks! > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/99c4f094-af21-409d-85fd-e89172c90be5%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.