Ring of algebraic integers as lattice points in the complex plane Let, $i=\sqrt{-1}$ and $\omega = e^{\frac{2\pi i}{3}}$.
I know that we can represent the ring of integers $\mathbb{Z}[i]$ and $\mathbb{Z}[\omega]$ as square and triangular lattice on complex plane respectively.
Motivated by this and this question I wish to know:

  
*
  
*Is there a way to plot such lattice diagrams for each and every ring
  of algebraic integer? If yes, then how?
  
*Is there a way to determine the shape of lattice units (rectangular, triangular,...) without actually plotting them?
  

By "how" I am asking for an example of code for a software (preferably open-source) which can be used to plot all such lattices.
 A: Someone else will deliver a more complete answer in due time, but for now, I'd like to answer your questions limited to imaginary quadratic integer rings. That is, if $d$ is a negative, squarefree integer, we're looking at the algebraic integers of $\mathbb{Q}(\sqrt{d})$, which we can notate as $\mathcal{O}_{\mathbb{Q}(\sqrt{d})}$, and $\mathbb{Z}[\sqrt{d}]$ if $d \not\equiv 1 \pmod 4$ (remember that $\omega = -\frac{1}{2} + \frac{\sqrt{-3}}{2}$; some people like to define $\theta = -\frac{1}{2} + \frac{\sqrt{d}}{2}$ and then use the $\mathbb{Z}[\theta]$ notation).
And really that congruence is what determines if the lattice is rectangular or triangular. If $d \not\equiv 1 \pmod 4$, then only numbers of the form $a + b \sqrt{d}$, with $a, b \in \mathbb{Z}$, are in $\mathbb{Z}[\sqrt{d}]$, and therefore the lattice will be rectangular. For example, in $\mathbb{Z}[\sqrt{-2}]$, we see that 1 lines up vertically with $1 + \sqrt{-2}$ and $1 - \sqrt{-2}$, $1 + 2 \sqrt{-2}$ and $1 - 2 \sqrt{-2}$, etc. And it lines up horizontally with all purely real integers of this domain.
Now let's look at $\mathcal{O}_{\mathbb{Q}(\sqrt{-7})}$. Since $-7 \equiv 1 \pmod 4$ (remember that $-7 = -2 \times 4 + 1$), the domain includes the so-called half-integers, such as $$\frac{5}{2} + \frac{\sqrt{-7}}{2}, -\frac{3}{2} + \frac{9 \sqrt{-7}}{2}, \frac{13}{2} - \frac{11 \sqrt{-7}}{2}, \ldots$$ Notice that in each case, in $$\frac{a}{2} + \frac{b \sqrt{-7}}{2},$$ both $a$ and $b$ are odd. If they're both even, we can simplify the fractions to integers.
But if one is odd and the other is even, then it's not an algebraic integer in this domain. Consider for example $$N\left(5 + \frac{\sqrt{-7}}{2}\right) = 5^2 + 7\left(\frac{1}{2}\right)^2 = 25 + \frac{7}{4},$$ which is not an integer. Furthermore, the minimal polynomial of this number is $4x^2 - 40x + 107$, which you can verify by hand calculations, or by asking Wolfram Alpha is 5 + sqrt(-7)/2 an algebraic integer? Change your WA query to is (5/2 + sqrt(-7)/2) an algebraic integer? (it seems to get confused without the parentheses, oh well) and it tells you that this number has a minimal polynomial of $x^2 - 5x + 8$.
So $$\frac{5}{2} + \frac{\sqrt{-7}}{2}$$ will not line up horizontally or vertically with $2 + \sqrt{-7}$, $3 + \sqrt{-7}$, 3 or 2. But if you draw a diagonal from $2 + \sqrt{-7}$ to 3 and another from 2 to $3 + \sqrt{-7}$, where do the two diagonals meet? Therefore, if $d \equiv 1 \pmod 4$, the lattice is triangular.
The following diagram I originally made because I was interested about the primes in $\mathcal{O}_{\mathbb{Q}(\sqrt{-7})}$.

If $a$ and $b$ are odd, only $|a| = |b| = 1$ gives a prime, specifically a prime with a norm of 2. For that reason, I did not bother to draw the diagonal lines, but for your benefit, I copied the $a$ and $b$ both even grid, lined it up to the primes of norm 2 and reduced its opacity. (The eagle-eyed will say that $-7$ and 7 need to be colored light blue or some color other than dark blue, and they're right, but it does not matter for your question).
A: This is not really an answer, but might be relevant. I record it as CW.
The ring of algebraic integers $R$ of a number field $K$, of degree $n$, is always a free $\mathbb{Z}$-module of rank $n$, that is there are elements $\omega_1, \dots, \omega_n$, called an integral basis, such that every element $r\in R$ has a unique representation of the form $r=\sum_{i=1}^n a_i \omega_i$ with $a_i$ integers. 
Various programs are able to compute the integral basis. To then print a selection of the relevant points is not hard, but it will often just yield a colored area as the set is dense.
The way to use the lattice structure effectively is described in a linked to answer.  
