Display an array as a matrix in a new figure window. The origin is set at the upper left hand corner and rows (first dimension of the array) are displayed horizontally. The aspect ratio of the figure window is that of the array, unless this would make an excessively short or n
(A, fignum=None, **kwargs)
| 2158 | |
| 2159 | |
| 2160 | def matshow(A, fignum=None, **kwargs): |
| 2161 | """ |
| 2162 | Display an array as a matrix in a new figure window. |
| 2163 | |
| 2164 | The origin is set at the upper left hand corner and rows (first |
| 2165 | dimension of the array) are displayed horizontally. The aspect |
| 2166 | ratio of the figure window is that of the array, unless this would |
| 2167 | make an excessively short or narrow figure. |
| 2168 | |
| 2169 | Tick labels for the xaxis are placed on top. |
| 2170 | |
| 2171 | Parameters |
| 2172 | ---------- |
| 2173 | A : array-like(M, N) |
| 2174 | The matrix to be displayed. |
| 2175 | |
| 2176 | fignum : None or int or False |
| 2177 | If *None*, create a new figure window with automatic numbering. |
| 2178 | |
| 2179 | If *fignum* is an integer, draw into the figure with the given number |
| 2180 | (create it if it does not exist). |
| 2181 | |
| 2182 | If 0 or *False*, use the current axes if it exists instead of creating |
| 2183 | a new figure. |
| 2184 | |
| 2185 | .. note:: |
| 2186 | |
| 2187 | Because of how `.Axes.matshow` tries to set the figure aspect |
| 2188 | ratio to be the one of the array, strange things may happen if you |
| 2189 | reuse an existing figure. |
| 2190 | |
| 2191 | Returns |
| 2192 | ------- |
| 2193 | image : `~matplotlib.image.AxesImage` |
| 2194 | |
| 2195 | Other Parameters |
| 2196 | ---------------- |
| 2197 | **kwargs : `~matplotlib.axes.Axes.imshow` arguments |
| 2198 | |
| 2199 | """ |
| 2200 | A = np.asanyarray(A) |
| 2201 | if fignum is False or fignum is 0: |
| 2202 | ax = gca() |
| 2203 | else: |
| 2204 | # Extract actual aspect ratio of array and make appropriately sized figure |
| 2205 | fig = figure(fignum, figsize=figaspect(A)) |
| 2206 | ax = fig.add_axes([0.15, 0.09, 0.775, 0.775]) |
| 2207 | |
| 2208 | im = ax.matshow(A, **kwargs) |
| 2209 | sci(im) |
| 2210 | |
| 2211 | return im |
| 2212 | |
| 2213 | |
| 2214 | def polar(*args, **kwargs): |