sdr.plot.constellation(x_hat: ArrayLike, limits: tuple[float, float] | None = None, persistence: bool = False, colorbar: bool = True, ax: Axes | None = None, **kwargs)

Plots the constellation of the complex symbols \(\hat{x}[k]\).

Parameters:
x_hat: ArrayLike

The complex symbols \(\hat{x}[k]\).

limits: tuple[float, float] | None = None

The axis limits, which apply to both the x- and y-axis. If None, the axis limits are set to 10% larger than the maximum value.

persistence: bool = False

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

colorbar: bool = True

Indicates whether to add a colorbar to the plot. This is only added if 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 Matplotlib functions.

If persistence=False, the following keyword arguments are passed to matplotlib.pyplot.scatter(). The defaults may be overwritten.

  • "marker": "."

  • "linestyle": "none"

If persistence=True, the following keyword arguments are passed to numpy.histogram2d() and matplotlib.pyplot.pcolormesh(). The defaults may be overwritten.

  • "range": +/- 10% of the maximum value

  • "bins": 100 # Number of bins per axis

  • "cmap": "rainbow"

  • "show_zero": False

Example

Display the symbol constellation for Gray-coded QPSK at 6 dB \(E_s/N_0\).

In [1]: qpsk = sdr.PSK(4, phase_offset=45); \
   ...: s = np.random.randint(0, qpsk.order, 100_000); \
   ...: x = qpsk.map_symbols(s); \
   ...: x_hat = sdr.awgn(x, 6);
   ...: 

In [2]: plt.figure(); \
   ...: sdr.plot.constellation(x_hat[0:1_000])
   ...: 
../../_images/sdr_plot_constellation_1.png

Display the symbol constellation using a persistence plot.

In [3]: plt.figure(); \
   ...: sdr.plot.constellation(x_hat, persistence=True)
   ...: 
../../_images/sdr_plot_constellation_2.png