Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents ba518b0 + 8315c19 commit a22443fCopy full SHA for a22443f
examples/images_contours_and_fields/matshow.py
@@ -3,22 +3,15 @@
3
Matshow
4
=======
5
6
-Simple `~.axes.Axes.matshow` example.
+`~.axes.Axes.matshow` visualizes a 2D matrix or array as color-coded image.
7
"""
8
import matplotlib.pyplot as plt
9
import numpy as np
10
11
+# a 2D array with linearly increasing values on the diagonal
12
+a = np.diag(range(15))
13
-def samplemat(dims):
- """Make a matrix with all zeros and increasing elements on the diagonal"""
14
- aa = np.zeros(dims)
15
- for i in range(min(dims)):
16
- aa[i, i] = i
17
- return aa
18
-
19
20
-# Display matrix
21
-plt.matshow(samplemat((15, 15)))
+plt.matshow(a)
22
23
plt.show()
24
0 commit comments