import numpy as np
import matplotlib.pyplot as plt

from skimage import data
from skimage.filter.rank import entropy
from skimage.morphology import disk
from skimage.util import img_as_ubyte


image = img_as_ubyte(data.camera())

plt.figure(figsize=(10, 4))

plt.subplot(121)
plt.imshow(image, cmap=plt.cm.gray)
plt.title('Image')
plt.colorbar()

plt.subplot(122)
plt.imshow(entropy(image, disk(5)), cmap=plt.cm.jet)
plt.title('Entropy')
plt.colorbar()

plt.show()

import numpy as np
import matplotlib.pyplot as plt

from skimage import data
from skimage.filter.rank import entropy
from skimage.morphology import disk
from skimage.util import img_as_ubyte


image = img_as_ubyte(data.camera())

fig, (ax0, ax1) = plt.subplots(ncols=2, figsize=(10, 4))


img0 = ax0.imshow(image, cmap=plt.cm.gray)
ax0.set_title('Image')
ax0.axis('off')
plt.colorbar(img0, ax=ax0)

img1 = ax1.imshow(entropy(image, disk(5)), cmap=plt.cm.jet)
ax1.set_title('Entropy')
ax1.axis('off')
plt.colorbar(img1, ax=ax1)

plt.show()

Update entropy example with improved matplotlib usage
Update entropy example with improved matplotlib usage

  import numpy as np
  import matplotlib.pyplot as plt
  
  from skimage import data
  from skimage.filter.rank import entropy
  from skimage.morphology import disk
  from skimage.util import img_as_ubyte
  
  
  image = img_as_ubyte(data.camera())
  
- plt.figure(figsize=(10, 4))
+ fig, (ax0, ax1) = plt.subplots(ncols=2, figsize=(10, 4))
  
- plt.subplot(121)
- plt.imshow(image, cmap=plt.cm.gray)
- plt.title('Image')
- plt.colorbar()
  
- plt.subplot(122)
+ img0 = ax0.imshow(image, cmap=plt.cm.gray)
+ ax0.set_title('Image')
+ ax0.axis('off')
+ plt.colorbar(img0, ax=ax0)
+ 
- plt.imshow(entropy(image, disk(5)), cmap=plt.cm.jet)
+ img1 = ax1.imshow(entropy(image, disk(5)), cmap=plt.cm.jet)
- plt.title('Entropy')
+ ax1.set_title('Entropy')
- plt.colorbar()
+ ax1.axis('off')
+ plt.colorbar(img1, ax=ax1)
  
  plt.show()
  
Update entropy example with improved matplotlib usage
## Code Before:
import numpy as np
import matplotlib.pyplot as plt

from skimage import data
from skimage.filter.rank import entropy
from skimage.morphology import disk
from skimage.util import img_as_ubyte


image = img_as_ubyte(data.camera())

plt.figure(figsize=(10, 4))

plt.subplot(121)
plt.imshow(image, cmap=plt.cm.gray)
plt.title('Image')
plt.colorbar()

plt.subplot(122)
plt.imshow(entropy(image, disk(5)), cmap=plt.cm.jet)
plt.title('Entropy')
plt.colorbar()

plt.show()

## Instruction:
Update entropy example with improved matplotlib usage
## Code After:
import numpy as np
import matplotlib.pyplot as plt

from skimage import data
from skimage.filter.rank import entropy
from skimage.morphology import disk
from skimage.util import img_as_ubyte


image = img_as_ubyte(data.camera())

fig, (ax0, ax1) = plt.subplots(ncols=2, figsize=(10, 4))


img0 = ax0.imshow(image, cmap=plt.cm.gray)
ax0.set_title('Image')
ax0.axis('off')
plt.colorbar(img0, ax=ax0)

img1 = ax1.imshow(entropy(image, disk(5)), cmap=plt.cm.jet)
ax1.set_title('Entropy')
ax1.axis('off')
plt.colorbar(img1, ax=ax1)

plt.show()
