Skip to content

Plotter

BasePlot

Base class for plotting graphs, implementing common functionality for all plots.

Parameters:

Name Type Description Default
ax Axes

Matplotlib Axes object.

required
title str

Plot title.

''
labels Optional[List[str]]

List of axis labels.

None
xlim Optional[Tuple[float, float]]

Limits of the x-axis x = [xlim[0], xlim[1]].

None
ylim Optional[Tuple[float, float]]

Limits of the y-axis y = [ylim[0], ylim[1]].

None
colors Optional[Union[str, List[str]]]

Plot colors.

None
style Optional[Dict[str, Any]]

Plot style.

None

GainPatternPlot

Bases: BasePlot

Example

pageplot

Parameters:

Name Type Description Default
ax Axes

Matplotlib Axes object.

required
title str

Plot title.

'Diagrama de Irradiação (dBi)'
labels Optional[List[str]]

List of axis labels.

required
xlim Optional[Tuple[float, float]]

Limits of the x-axis x = [xlim[0], xlim[1]].

required
ylim Optional[Tuple[float, float]]

Limits of the y-axis y = [ylim[0], ylim[1]].

required
colors Optional[Union[str, List[str]]]

Plot colors.

None
style Optional[Dict[str, Any]]

Plot style.

None

TimePlot

Bases: BasePlot

Class for plotting signals in the time domain, receiving a time vector \(t\), and a list of signals \(s(t)\).

Parameters:

Name Type Description Default
fig Figure

Figure object

required
grid GridSpec

GridSpec object

required
pos int

Plot position

required
t ndarray

Time vector

required
signals Union[ndarray, List[ndarray]]

Signal or list of signals \(s(t)\).

required
time_unit str

Time unit for plotting ("ms" by default, can be "s").

'ms'
amp_norm bool

Signal normalization for maximum amplitude

False

Examples:

  • Modulator Time Domain Example: pageplot
  • AWGN addition Time Domain Example: pageplot

FrequencyPlot

Bases: BasePlot

Class for plotting signals in the frequency domain, receiving a sampling frequency \(f_s\) and a signal \(s(t)\) and performing the Fourier transform of the signal, according to the expression below.

\[ \begin{equation} S(f) = \mathcal{F}\{s(t)\} \end{equation} \]
Where
  • \(S(f)\): Signal in the frequency domain.
  • \(s(t)\): Signal in the time domain.
  • \(\mathcal{F}\): Fourier transform.

Parameters:

Name Type Description Default
fig Figure

Figure object

required
grid GridSpec

GridSpec object

required
pos int

Plot position

required
fs float

Sampling frequency

required
signal ndarray

Signal to be plotted

required
fc float

Central frequency

0.0

Examples:

  • Modulator Frequency Domain Example: pageplot
  • AWGN addition Frequency Domain Example: pageplot

TxRxSignalPlot

Bases: BasePlot

Plotador de sinais TX e RX em dB, recebendo vetores diretamente, seguindo o padrão do plotter.py (herda BasePlot).

FrequencyResponsePlot

Bases: BasePlot

Plot the frequency response of a filter from its coefficients (b, a). Calculates the Discrete Fourier Transform of the impulse response using scipy.signal.freqz.

\[ H(f) = \sum_{n=0}^{N} b_n e^{-j 2 \pi f n} \Big/ \sum_{m=0}^{M} a_m e^{-j 2 \pi f m} \]

Parameters:

Name Type Description Default
fig Figure

Figure of the plot

required
grid GridSpec

GridSpec of the plot

required
pos int

Position in the GridSpec

required
b ndarray

Coefficients of the numerator of the filter

required
a ndarray

Coefficients of the denominator of the filter

required
fs float

Sampling frequency

required
f_cut Optional[float]

Cut-off frequency of the filter (Hz)

None
xlim Optional[Tuple[float, float]]

Limit of the x-axis (Hz)

None
worN int

Number of points for the Discrete Fourier Transform

1024
show_phase bool

If True, plots the phase of the frequency response

False
xlabel str

Label of the x-axis

'Frequency (Hz)'
ylabel str

Label of the y-axis

'Magnitude (dB)'

Examples:

  • Frequency Domain Plot Example: pageplot

create_figure(rows, cols, figsize=(16, 9))

Creates a figure with GridSpec, returning the fig and grid objects for plotting.

Parameters:

Name Type Description Default
rows int

Number of rows in the GridSpec

required
cols int

Number of columns in the GridSpec

required
figsize Tuple[int, int]

Figure size

(16, 9)

Returns:

Type Description
Tuple[Figure, GridSpec]

Tuple[plt.Figure, gridspec.GridSpec]: Tuple with the figure and GridSpec objects

save_figure(fig, filename, out_dir='../../../assets')

Saves the figure in <out_dir>/<filename> from the script root directory.

Parameters:

Name Type Description Default
fig Figure

Matplotlib Figure object

required
filename str

Output file name

required
out_dir str

Output directory

'../../../assets'

Raises:

Type Description
ValueError

If the output directory is invalid