numpy.rot90()

numpy.rot90

numpy.rot90(m, k=1) [source]

Rotate an array by 90 degrees in the counter-clockwise direction.

The first two dimensions are rotated; therefore, the array must be at least 2-D.

Parameters:

m : array_like

Array of two or more dimensions.

k : integer

Number of times the array is rotated by 90 degrees.

Returns:

y : ndarray

Rotated array.

See also

fliplr
Flip an array horizontally.
flipud
Flip an array vertically.

Examples

>>> m = np.array([[1,2],[3,4]], int)
>>> m
array([[1, 2],
       [3, 4]])
>>> np.rot90(m)
array([[2, 4],
       [1, 3]])
>>> np.rot90(m, 2)
array([[4, 3],
       [2, 1]])

© 2008–2016 NumPy Developers
Licensed under the NumPy License.
https://docs.scipy.org/doc/numpy-1.11.0/reference/generated/numpy.rot90.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部