Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e2c86e4

Browse files
committed
pngsuite test: plot images in grayscale if the input array is 2 dimensional
svn path=/branches/v0_98_5_maint/; revision=7027
1 parent 244812e commit e2c86e4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

examples/tests/pngsuite/pngsuite.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"""
99

1010
from matplotlib import pyplot as plt
11+
import matplotlib.cm as cm
1112
import glob
1213

1314
files = glob.glob("basn*.png")
@@ -17,7 +18,11 @@
1718

1819
for i, fname in enumerate(files):
1920
data = plt.imread(fname)
20-
plt.imshow(data, extent=[i,i+1,0,1])
21+
cmap = None # use default colormap
22+
if data.ndim==2:
23+
# keep grayscale images gray
24+
cmap = cm.gray
25+
plt.imshow(data, extent=[i,i+1,0,1], cmap=cmap)
2126

2227
plt.gca().get_frame().set_facecolor("#ddffff")
2328
plt.gca().set_xlim(0, len(files))

0 commit comments

Comments
 (0)