This example demonstrates how to generate a simple 3-dimensional plot of the data in an `SHGrid`

class instance. We start by generating a set of spherical harmonic coefficients that is zero, whith the exception of a single harmonic:

In [1]:

```
%matplotlib inline
import numpy as np
import pyshtools
```

In [2]:

```
pyshtools.utils.figstyle(rel_width=0.75)
%config InlineBackend.figure_format = 'retina' # if you are not using a retina display, comment this line
```

In [3]:

```
lmax = 30
coeffs = pyshtools.SHCoeffs.from_zeros(lmax)
coeffs.set_coeffs(values=[1], ls=[10], ms=[0])
```

To plot the data, we first expand it on a grid, and then use the method `plot3d()`

:

In [4]:

```
grid = coeffs.expand()
fig, ax = grid.plot3d(elevation=20, azimuth=30, show=False) # show=False is used to avoid a warning when plotting in inline mode
```

Let's try a somewhat more complicated function. Here we will calculate a random realization of a process whose power spectrum follows a power law with exponent `-2`

:

In [5]:

```
ldata = 30
degrees = np.arange(ldata+1, dtype=float)
degrees[0] = np.inf
power = degrees**(-2)
coeffs2 = pyshtools.SHCoeffs.from_random(power, seed=12345)
grid2 = coeffs2.expand()
fig, ax = grid2.plot3d(elevation=20, azimuth=30, show=False)
```