-
sdr.plot.time_domain(x: NDArray, sample_rate: float | None =
None
, centered: bool =False
, offset: float =0
, diff: 'color' | 'line' ='color'
, **kwargs) Plots a time-domain signal \(x[n]\).
- Parameters:¶
- x: NDArray¶
The time-domain signal \(x[n]\).
- 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 “Samples”.- centered: bool =
False
¶ Indicates whether to center the x-axis about 0. This argument is mutually exclusive with
offset
.- offset: float =
0
¶ The x-axis offset to apply to the first sample. The units of the offset are \(1/f_s\). This argument is mutually exclusive with
centered
.- diff: 'color' | 'line' =
'color'
¶ Indicates how to differentiate the real and imaginary parts of a complex signal. If
"color"
, the real and imaginary parts will have different colors based on the current Matplotlib color cycle. If"line"
, the real part will have a solid line and the imaginary part will have a dashed line, and both lines will share the same color.- **kwargs¶
Additional keyword arguments to pass to
matplotlib.pyplot.plot()
.
Examples¶
# Create a BPSK impulse signal In [1]: x = np.zeros(1000); \ ...: symbol_map = np.array([1, -1]); \ ...: x[::10] = symbol_map[np.random.randint(0, 2, 100)] ...: # Pulse shape the signal with a square-root raised cosine filter In [2]: h_srrc = sdr.root_raised_cosine(0.5, 7, 10); \ ...: y = np.convolve(x, h_srrc) ...: In [3]: plt.figure(figsize=(8, 4)); \ ...: sdr.plot.time_domain(y, sample_rate=10e3); \ ...: plt.title("SRRC pulse-shaped BPSK"); \ ...: plt.tight_layout() ...:
# Create a QPSK impulse signal In [4]: x = np.zeros(1000, dtype=complex); \ ...: symbol_map = np.exp(1j * np.pi / 4) * np.array([1, 1j, -1, -1j]); \ ...: x[::10] = symbol_map[np.random.randint(0, 4, 100)] ...: # Pulse shape the signal with a square-root raised cosine filter In [5]: h_srrc = sdr.root_raised_cosine(0.5, 7, 10); \ ...: y = np.convolve(x, h_srrc) ...: In [6]: plt.figure(figsize=(8, 4)); \ ...: sdr.plot.time_domain(y, sample_rate=10e3); \ ...: plt.title("SRRC pulse-shaped QPSK"); \ ...: plt.tight_layout() ...: