# Revision history [back]

Compare the output of

list_plot([-1, 1, -1+I, -1-I], size=80)

with that of

list_plot([-1, 1], size=80) + list_plot([-1+I, -1-I], size=80)

In the fisrt case, you see four points located at $(-1,0)$, $(1,0)$, $(-1,1)$ and $(-1,-1)$. This is the correct way to place $-1$, $1$, $-1+I$ and $-1-I$ in the complex plane. However, in the second case, you get four points located at $(0,-1)$, $(1,1)$, $(-1,1)$ and $(-1,-1)$, which is not what you can expect.

The problem comes from the way list_plot interprets its argument. If the list contains a complex number, list_plot thinks that every element $z$ of the list is a complex number and places it at $(x,y)$, $x$ and $y$ being the real and imaginary parts of $z$. If the list only contains real numbers, say, $x_0, x_1, x_2\ldots$, list_plot places them at $(0,x_0)$, $(1,x_1)$, $(2,x_2)$ and so on.

I conjecture that some list in roots only contains real numbers. So some list_plot in the code

sum(list_plot(i) for i in roots)

may misinterpret its argument and draw points at undesired locations. However, when you unify all the roots in a single list, since it contains at least one complex number, list_plot behaves as expected. By the way, you can construct such a unique list in simpler ways. For example,

allroots = []
for period in roots:
allroots += period
pic = list_plot(allroots)

Or just

pic = flatten(roots)

Compare the output of

list_plot([-1, 1, -1+I, -1-I], size=80)

with that of

list_plot([-1, 1], size=80) + list_plot([-1+I, -1-I], size=80)

In the fisrt case, you see four points located at $(-1,0)$, $(1,0)$, $(-1,1)$ and $(-1,-1)$. This is the correct way to place $-1$, $1$, $-1+I$ and $-1-I$ in the complex plane. However, in the second case, you get four points located at $(0,-1)$, $(1,1)$, $(-1,1)$ and $(-1,-1)$, which is not what you can expect.

The problem comes from the way list_plot interprets its argument. If the list contains a complex number, list_plot thinks that every element $z$ of the list is a complex number and places it at $(x,y)$, $x$ and $y$ being the real and imaginary parts of $z$. If the list only contains real numbers, say, $x_0, x_1, x_2\ldots$, list_plot places them at $(0,x_0)$, $(1,x_1)$, $(2,x_2)$ and so on.

I conjecture that some list in roots only contains real numbers. So some list_plot in the code

sum(list_plot(i) for i in roots)

may misinterpret its argument and draw points at undesired locations. However, when you unify all the roots in a single list, since it contains at least one complex number, list_plot behaves as expected. By the way, you can construct such a unique list in simpler ways. For example,

allroots = []
for period in roots:
allroots += period
pic = list_plot(allroots)

Or just

pic = flatten(roots)
list_plot(flatten(roots))