I want to create list, so I used:
x_ticks=np.arange(x1, x2, 6) print(x_ticks) print(type(x_ticks)) print(x_ticks)
The result is:
[-1.15e-14] <class 'numpy.ndarray'> Traceback (most recent call last): File "el_motion.py", line 371, in <module> print(x_ticks) IndexError: index 5 is out of bounds for axis 0 with size 1
Why there are not 6 elements printed? Thank you
How to plot small lines in 3d using this list and for cycle?
x1=-1.15e-14 x2=0.009e-14 x_ticks=np.linspace(x1, x2, 6) print(x_ticks) print(type(x_ticks)) print(x_ticks) stepx=(x2-x1)/6 print(stepx) for xi in range(1, 6): ax.plot([xi*stepx, xi*stepx], [-6.3e-15, -6.4e-15], [0,0])
the result is one line that is not on the desired place.
My guess is that the difference between x1 and x2 is less that the provided step interval (6). For example:
[1, 2, 3, 4]
np.arange(1, 5, 6)
6 is too large of a step, therefore it returns only the first value
np.linspace(x1, x2, 6) on the other hand, will return x1 one and x2 evenly spaced increments between, resulting in 6 numbers