The python code below creates data for a numpy array that I use to graph a unit box on a graph:
box = np.array([[x, y] for x in np.arange(0.0, 1.01, 0.01) for y in
np.arange(0.0, 1.01, 0.01)])
I want to transform box
-- by adding a number to the x component and a different number to the y component -- into another numpy array so the new box appears elsewhere on the graph.
I am having some trouble figuring out if I can slice a numpy array to do the addition I need or what the correct loop syntax would be.
My question is: how do I add, say 1 to each x element and 3 to each y element?
So, if some element in the initial numpy array was [0.8, 0.5]
, that particular element would then be (in the new array): [1.8, 3.5]
. All other elements would also have their x and y values updated the same way.