This is a pre-release version (latest). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy latest / numpy / rot90

_ArrayFunctionDispatcher

numpy:rot90

source: /dev/numpy/build-install/usr/lib/python3.14/site-packages/numpy/lib/_function_base_impl.py :178

Signature

def   rot90 ( m k = 1 axes = (0, 1) )

Summary

Rotate an array by 90 degrees in the plane specified by axes.

Extended Summary

Rotation direction is from the first towards the second axis. This means for a 2D array with the default k and axes, the rotation will be counterclockwise.

Parameters

m : array_like

Array of two or more dimensions.

k : integer

Number of times the array is rotated by 90 degrees.

axes : (2,) array_like

The array is rotated in the plane defined by the axes. Axes must be different.

Returns

y : ndarray

A rotated view of m.

Notes

rot90(m, k=1, axes=(1,0)) is the reverse of rot90(m, k=1, axes=(0,1))

rot90(m, k=1, axes=(1,0)) is equivalent to rot90(m, k=-1, axes=(0,1))

Examples

import numpy as np
m = np.array([[1,2],[3,4]], int)
m
np.rot90(m)
np.rot90(m, 2)
m = np.arange(8).reshape((2,2,2))
np.rot90(m, 1, (1,2))

See also

flip

Reverse the order of elements in an array along the given axis.

fliplr

Flip an array horizontally.

flipud

Flip an array vertically.

Aliases

  • numpy.rot90