I understand the concept. But I think I am making a silly mistake. This is what I want (psuedo-ish code). This is for an exercise. I am unable to understand lower origin part and the syntax of the first two lines.
norm = LogNorm(image.mean() + 0.5 * image.std(), image.max(), clip='True',
cmap=cm.gray, origin="lower")
image
is a numpy array here. How to pass these norm
and cmap
parameters in matplotlib to plt.show
or imshow()
?
This doesn't work:
imshow(image, cmap=cm.gray, LogNorm(......))
Does this work?
from matplotlib import colors, cm, pyplot as plt
norm = colors.LogNorm(image.mean() + 0.5 * image.std(), image.max(), clip='True')
plt.imshow(image, cmap=cm.gray, norm=norm, origin="lower")
This creates a special colormap that ranges from image.mean() + 0.5 * image.std()
to image.max()
using a logarithmic scale. More general information is here: colors
and specifically: LogNorm
The origin='lower'
means that the [0,0]
element (the 'origin') of the array is shown in the lower left part of the figure. Normally the origin of an array is in the upper left.
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