I have a 2D matrix containing zeros and ones. The ones define a shape from which I want to plot its contour/edge on a matplotlib figure. The initial 2D binary matrix:
[[0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 1 1 1 1 1 0 0 0]
[0 0 0 1 1 1 1 1 0 0 0]
[0 0 0 1 1 1 1 1 0 0 0]
[0 0 0 1 1 1 1 1 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0]]
I found here the method to get the corresponding 2D binary matrix of the edge of the shape:
[[0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 1 1 1 1 1 0 0 0]
[0 0 0 1 0 0 0 1 0 0 0]
[0 0 0 1 0 0 0 1 0 0 0]
[0 0 0 1 1 1 1 1 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0]]
Using plt.imshow, I get the following result:

How would you do to plot the ones in this matrix as a dotted line in a matplotlib figure using plt.plot() ? I would like to get this result:




