sdr.plot.eye(x: ArrayLike, sps: int, span: int = 2, sample_rate: float | None = None, color: 'index' | str = 'index', persistence: bool = False, colorbar: bool = True, ax: Axes | None = None, **kwargs)

Plots the eye diagram of the baseband modulated signal \(x[n]\).

Parameters:
x: ArrayLike

The baseband modulated signal \(x[n]\). If x is complex, in-phase and quadrature eye diagrams are plotted in separate subplots.

sps: int

The number of samples per symbol.

span: int = 2

The number of symbols per raster.

sample_rate: float | None = None

The sample rate \(f_s\) of the signal in samples/s. If None, the x-axis will be labeled as “Symbol”.

color: 'index' | str = 'index'

Indicates how to color the rasters. If "index", the rasters are colored based on their index. If a valid Matplotlib color, the rasters are all colored with that color.

persistence: bool = False

Indicates whether to plot the raster as a persistence plot. A persistence plot is a 2D histogram of the rasters.

colorbar: bool = True

Indicates whether to add a colorbar to the plot. This is only added if color="index" or persistence=True.

ax: Axes | None = None

The axis to plot on. If None, the current axis is used.

**kwargs

Additional keyword arguments to pass to sdr.plot.raster().

Example

Modulate 1,000 QPSK symbols using a square root raised cosine (SRRC) pulse shaping filter. The SRRC pulse shape is not a Nyquist filter, and intersymbol interference (ISI) can be observed in the eye diagram. Plot the eye diagram using index-colored rasters. Note, we are ignoring the transient response of the pulse shaping filter at the beginning and end of the signal.

In [1]: psk = sdr.PSK(4, phase_offset=45, pulse_shape="srrc"); \
   ...: sps = psk.sps; \
   ...: s = np.random.randint(0, psk.order, 1_000); \
   ...: tx_samples = psk.modulate(s)
   ...: 

In [2]: plt.figure(figsize=(8, 6)); \
   ...: sdr.plot.eye(tx_samples[4*sps : -4*sps], sps); \
   ...: plt.suptitle("Transmitted QPSK symbols with SRRC pulse shape");
   ...: 
../../_images/sdr_plot_eye_1.png

Plot the eye diagram using a persistence plot. This provides insight into the probability density function of the signal.

In [3]: plt.figure(figsize=(8, 6)); \
   ...: sdr.plot.eye(tx_samples[4*sps : -4*sps], sps, persistence=True); \
   ...: plt.suptitle("Transmitted QPSK symbols with SRRC pulse shape");
   ...: 
../../_images/sdr_plot_eye_2.png

Apply a SRRC matched filter at the receiver. The cascaded transmit and receive SRRC filters are equivalent to a single raised cosine (RC) filter, which is a Nyquist filter. ISI is no longer observed, and the eye is open.

In [4]: mf = sdr.FIR(psk.pulse_shape); \
   ...: rx_samples = mf(tx_samples, mode="same")
   ...: 

In [5]: plt.figure(figsize=(8, 6)); \
   ...: sdr.plot.eye(rx_samples[4*sps : -4*sps], sps, persistence=True); \
   ...: plt.suptitle("Received and matched filtered QPSK symbols");
   ...: 
../../_images/sdr_plot_eye_3.png