1
votes

I am trying to plot map data given in CSV format for performing robot localization. I have a numpy 2D array called map which indexes onto the probability value that the robot is at that grid position.

E.g. map[500, 375] = 0.75 means there is a 75% chance of the robot being at grid 500, 375.

Currently I am using matplotlib's surface_plot function to plot a 3D height map, but I wish to use matplotlib to plot a 2D color map where instead of height, the probability is represented by a particular color.

Any ideas on how can I do this?

1

1 Answers

1
votes

Actually I'm not sure if it's what you need but I think you might want to take a look at plt.imshow(). It has a large variety of colormaps.

For example to plot something using a hot-cmap:

plt.imshow(map, origin='lower', cmap="hot", interpolation='none')

The parameters are actually not very important, the origin is (from my perspective) confusing that 0,0 is top left by default and you need to specify 'lower' if you want 0,0 to be bottom left. The interpolation can be omitted if you want some kind of interpolation but if you don't want any then you need to define it as 'none'.

A list of all possible colormaps can be found in one of matplotlibs example codes.