# Reshape

How to change the dimensions of a NumPy array.

#### New to Plotly?¶

Plotly's Python library is free and open source! Get started by downloading the client and reading the primer.

You can set up Plotly to work in online or offline mode, or in jupyter notebooks.

We also have a quick-reference cheatsheet (new!) to help you get started!

```
import plotly.plotly as py
from plotly.tools import FigureFactory as FF
import numpy as np
```

#### Reshape an Array¶

`.reshape()`

is a numpy array method that is used to reconstruct the given array into another shape with different dimensions. For a 1D array of the form

of length $L$ we can reshape into an matrix-looking array with $R$ rows and $C$ columns where

$$ \begin{align*} R \times C = L \end{align*} $$For example the array $[1, 2, 3, 4, 5, 6]$ could be reshaped into this matrix-like array (i.e. just an array of arrays) with `2`

rows and and `3`

columns:

```
import plotly.plotly as py
from plotly.tools import FigureFactory as FF
z = np.arange(10).reshape((2, 5))
fig = FF.create_annotated_heatmap(z, colorscale='Viridis')
py.iplot(fig, filename='numpy-reshape-1')
```

```
import plotly.plotly as py
from plotly.tools import FigureFactory as FF
z = np.arange(10).reshape((5, 2))
fig = FF.create_annotated_heatmap(z, colorscale='Viridis')
py.iplot(fig, filename='numpy-reshape-2')
```

```
import plotly.plotly as py
from plotly.tools import FigureFactory as FF
z = [np.arange(10).reshape(10)]
fig = FF.create_annotated_heatmap(z, colorscale='Viridis')
py.iplot(fig, filename='numpy-reshape-3')
```

```
help(np.reshape)
```