puncturedfem.plot.TracePlot
Plot traces of functions on the boundary of a MeshCell.
Attributes:
| Name | Type | Description |
|---|---|---|
fig_handle |
plt.Figure
|
The handle to the figure. |
t |
np.ndarray
|
The parameter values for the traces. |
traces |
list[np.ndarray]
|
The traces to be plotted. |
x_ticks |
np.ndarray
|
The ticks for the x-axis. |
x_labels |
list[str]
|
The labels for the x-axis. |
num_pts |
int
|
The number of sampled boundary points of the MeshCell. |
fmt |
Union[str, list[str]]
|
The format string(s) used to plot the traces. |
legend |
tuple
|
The legend for the plot. |
title |
str
|
The title for the plot. |
log_scale |
bool
|
Whether or not to use a log scale on the vertical axis. |
show_grid |
bool
|
Whether or not to display a grid on the plot. |
__init__(traces, K, quad_dict, fmt='k-', legend=(), title='', log_scale=False, show_grid=True, max_num_ticks=9)
Initialize a TracePlot object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
traces |
Union[TraceLike, list[TraceLike]]
|
The traces to be plotted. Each trace must be a DirichletTrace or a numpy.ndarray of the same length as the number of sampled boundary points of the MeshCell. |
required |
K |
MeshCell
|
The MeshCell whose boundary the traces are sampled on |
required |
quad_dict |
dict[str, Quad]
|
A dictionary of the quadrature rules used to sample the boundary of the MeshCell |
required |
fmt |
str or list of str, optional
|
The format string(s) used to plot the traces. If a single string is given, it is used for all traces. If a list of strings is given that is the same length as traces, each string is used for the corresponding trace. The default is "k-", which plots the traces as black solid lines. |
'k-'
|
legend |
tuple of str, optional
|
The legend for the plot. The default is (), which does not display a legend. Must be a tuple of strings of the same length as traces. |
()
|
title |
str, optional
|
The title for the plot. The default is "", which does not display a title. |
''
|
log_scale |
bool, optional
|
Whether or not to use a log scale on the vertical axis. The default is False, which uses a linear scale. |
False
|
show_grid |
bool, optional
|
Whether or not to display a grid on the plot. The default is True, which displays a grid. |
True
|
max_num_ticks |
int, optional
|
The maximum number of ticks to display on the x-axis. The default is 9. |
9
|
draw(show_plot=True, filename='')
Draw the plot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
show_plot |
bool, optional
|
Whether to show the plot. The default is True. |
True
|
filename |
str, optional
|
The filename to save the plot to. The default is "", which results in no file being saved. |
''
|
set_format(fmt)
Set the format string(s) used to plot the traces.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fmt |
str or list of str
|
The format string(s) used to plot the traces. If a single string is given, it is used for all traces. If a list of strings is given that is the same length as traces, each string is used for the corresponding trace. |
required |
set_grid(show_grid)
Set whether or not to display a grid on the plot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
show_grid |
bool
|
Whether or not to display a grid on the plot. |
required |
set_legend(legend)
Set the legend for the plot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
legend |
tuple of str
|
The legend for the plot. Must be a tuple of strings of the same length as traces. |
required |
set_log_scale(log_scale)
Set whether or not to use a log scale on the vertical axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_scale |
bool
|
Whether or not to use a log scale on the vertical axis. |
required |
set_title(title)
Set the title for the plot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title |
str
|
The title for the plot. |
required |
set_traces(traces)
Set the traces to be plotted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
traces |
Union[TraceLike, list[TraceLike]]
|
The traces to be plotted. Each trace must be a DirichletTrace or a numpy.ndarray of the same length as the number of sampled boundary points of the MeshCell. |
required |