I am trying to visualise the path it took to reach from top left to bottom right. I have calculated updated the cost of each cells.. now trying to visualise the path.
i.e.
[[ 4 4 7 10 13]
[ 5 7 9 13 13]
[ 5 9 11 12 12]
[ 6 7 7 8 12]
[ 9 7 10 8 10]]
map is the above matrix. Starting from bottom right, I want to check if neighbours is small or equal, then x,y moves to that position. And changing the value to Nan so that it will come up as bad in the visualisation on matplotlib.
But it is throwing "ValueError: cannot convert float NaN to integer".
Can someone please advice on how to solve this?
```
origingrid=np.ones((row,col),dtype=int)*np.nan
#Start backtracking to plot the path
temp=map.astype(float)
x,y=row-1,col-1
path=[]
#set the lower right cell to be nan.
temp[np.int(x),np.int(y)]=np.nan
while x>0.0 or y>0.0:
path.append([np.int(x),np.int(y)])
if map[x][y-1] <= map[x][y]:
origingrid[x,y-1] = np.ravel_multi_index([x,y], (row,col))
xy=np.unravel_index(np.int(origingrid[np.int(x),np.int(y)]), (row,col)) #<--ValueError: cannot convert float NaN to integer
x,y = xy[0],xy[1]
else:
origingrid[x-1,y] = np.ravel_multi_index([x,y], (row,col))
xy=np.unravel_index(np.int(origingrid[np.int(x),np.int(y)]), (row,col))
x,y = xy[0],xy[1]
temp[np.int(x),np.int(y)]=np.nan
path.append([np.int(x),np.int(y)])
```