I'm plotting a NumPy array as a contour plot using matplotlib:
import numpy as np
import matplotlib.pyplot as plt
plt.contour(array, linewidths = 1, colors = 'k')
plt.contourf(array, cmap = plt.cm.jet)
plt.colorbar()
plt.show()
I would like to add a 'crosshair' or another marker to denote the maximum value in the array which is given by:
maxi = np.max(array)
How should I go about doing this?
You can simply plot the cross if you know the position.
[row, col] = numpy.where(array==np.max(array))
plt.plot(col, row, 'b+')
To change the markersize check this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With