Figures
Bellow you can find the documentation of figure-plotting functions.
Basic
smartreport.v3.plot.figures.basic.plot_background_text(text, **kwargs)
Makes an empty figure with background text.
Can be useful to plot the placeholder image when the data is missing or the plot is not supported.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text to be displayed in the background. |
required |
Other Parameters:
| Name | Type | Description |
|---|---|---|
figsize |
Tuple[int, int]
|
Defines the proportion of the figure. Default: |
layout |
BaseLayout
|
Layout to be used. Default: |
Returns:
| Type | Description |
|---|---|
Figure
|
Figure with background text. |
Drive KPIs
smartreport.v3.plot.figures.drive_kpi.plot_drive_kpi_trend(df, **kwargs)
Makes a figure with two subplots. Top plot shows a trend of measured value, against the thresholds and min-max limits (if provided). The bottom one plots a timeline of the KPI value.
Since both subplots are drawn against the same time range, they do share the X axis.
The figure uses a custom TrendWithTimelineLayout layout, based on the VerticalPlotLayout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Data frame with Drive KPI data. |
required |
Other Parameters:
| Name | Type | Description |
|---|---|---|
line_color |
str
|
Color of the trend line. Default: |
name |
str
|
Name of the KPI. Default `` |
trend_key |
str
|
Name of the column with trend values. If not provided, trend plot timeline is not plotted. |
min_trend_key |
str
|
Name of the column with min values. If not provided, min-max area is not plotted. |
max_trend_key |
str
|
Name of the column with max values. If not provided, min-max area is not plotted. |
kpi_trend_key |
str
|
Name of the column with KPI values.
If not provided, KPI timeline is not plotted. Default: |
low_threshold |
Threshold
|
Low threshold to be plotted on trend plot. If not provided, Low threshold is not plotted |
high_threshold |
Threshold
|
High threshold to be plotted on trend plot. If not provided, High threshold is not plotted |
unit |
str
|
Unit of the trend signal. Default: `` |
legend_labels |
Dict[str, str]
|
Labels for the plot. Default: |
Returns:
| Type | Description |
|---|---|
Figure
|
Figure with Drive KPI plot. |
smartreport.v3.plot.figures.drive_kpi.plot_climatic_condition_kpi_scatter(df, limits, **kwargs)
Makes a figure with climatic condition points plotted against climatic condition limits.
First, it draws climatic condition limits provided as a sequence of Polygon objects
using draw_polygon function.
Then the climatic condition points are drawn using draw_scatter_points on the 2d plane. By default, the
X axis is temperature and the Y Axis is relative humidity.
The figure uses the VerticalPlotLayout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Data frame with Drive KPI data. |
required |
limits
|
Sequence[Polygon]
|
Sequence of limits represented as |
required |
Other Parameters:
| Name | Type | Description |
|---|---|---|
x_key |
str
|
Key of the X values in the provided data frame. Default: |
y_key |
str
|
Key of the Y values in the provided data frame. Default: |
x_title |
str
|
Title of the X axis. Default: |
y_title |
str
|
Title of the Y axis. Default: |
x_unit |
str
|
Unit of the X values. Default: |
y_unit |
str
|
Unit of the Y values. Default: |
limit_colors |
Sequence[str]
|
Sequence of the limit polygon colors. Must be in sync with provided |
limit_names |
Sequence[str]
|
Sequence of the limit polygon names. Must be in sync with provided |
name |
str
|
Name of the scatter points. Default `` |
figsize |
Tuple[int, int]
|
Defines the proportion of the figure. Default: |
Returns:
| Type | Description |
|---|---|
Figure
|
Figure with Drive KPI plot. |
Timeline
smartreport.v3.plot.figures.timeline.plot_kpi_timeline(df, **kwargs)
Makes a figure KPI timeline plot for a single asset.
This plot uses draw_timeline function to represent KPI state on a datetime X axis.
The figure uses the TimelinePlotLayout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Data frame with Drive KPI data. The data should come from a single asset. |
required |
Other Parameters:
| Name | Type | Description |
|---|---|---|
name |
str
|
Name of the KPI. Default `` |
kpi_column_name |
str
|
Name of the column with KPI values.
If not provided, KPI timeline is not plotted. Default: |
figsize |
Tuple[int, int]
|
Defines the proportion of the figure. Default: |
Returns:
| Type | Description |
|---|---|
Figure
|
Figure with Timeline KPI plot. |
smartreport.v3.plot.figures.timeline.plot_kpi_timelines(df, **kwargs)
Makes a figure with KPI timeline plot for the fleet of assets.
This plot uses draw_timelines function to represent KPI states on a datetime X axis.
It expects the input data to be provided as a DataFrame with id_column_name column identifying the asset,
and kpi_column_name column with KPI values.
The figure uses the TimelinePlotLayout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Data frame with Drive KPI data. The data should come from one or more assets. Assets are identified by
|
required |
Other Parameters:
| Name | Type | Description |
|---|---|---|
name |
str
|
Name of the KPI. Default `` |
kpi_column_name |
str
|
Name of the column with KPI values.
If not provided, KPI timeline is not plotted. Default: |
id_column_name |
str
|
Name of the column with asset id. Default: |
figsize |
Tuple[int, int]
|
Defines the proportion of the figure. Default: |
color_mapping |
Dict
|
Dictionary that maps the values in the |
label_mapping |
Dict
|
Dictionary that maps the values in the |
show_all_items_on_legend |
bool
|
If True, then all the items from the |
Returns: Figure with Timeline KPI plot.
Donut
smartreport.v3.plot.figures.donut.plot_donut(charts, **kwargs)
Makes a figure with donut plot.
The donut plot is based on provided sequence of ChartElement objects.
Those object contains all information needed to create a plot. That includes: name, value
and optionally color, and extra_text.
The legend of each element is build in following way:
name
<b>extra_text</b>
The figure uses the DonutPlotLayout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
charts
|
Sequence[ChartElement]
|
Sequence of Chart Element object that contains information about pie chart elements. |
required |
Other Parameters:
| Name | Type | Description |
|---|---|---|
color |
Sequence[str]
|
List of colors as strings. They are only used if the |
figsize |
Tuple[int, int]
|
Defines the proportion of the figure. Default: |
Returns:
| Type | Description |
|---|---|
Figure
|
Figure with Donut plot. |
Signals
smartreport.v3.plot.figures.signals.plot_signal_in_time(signal, **kwargs)
Makes a figure that shows a RawDataSignal in a time domain. The Y-axis is the signal value in signal units, and the X-axis is the time in seconds. Time starts from 0.0 seconds.
This is a basic line plot, with no threshold or any other information.
The figure uses a custom VerticalPlotLayout layout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signal
|
RawDataSignal
|
RawDataSignal to be plotted. |
required |
Other Parameters:
| Name | Type | Description |
|---|---|---|
layout |
BaseLayout
|
Layout to be used. Default: |
title |
str
|
Title of the plot. Default: |
color |
str
|
Color of the line. Default: |
x1_axis_title |
str
|
Title of the X-axis. Default: |
y1_axis_title |
str
|
Title of the Y-axis. Default: |
wrap_y_label |
bool
|
Whether to wrap Y-axis label. Default: |
use_scattergl |
bool
|
Whether to use a Scattergl trace type. Default: |
Returns:
| Type | Description |
|---|---|
FT
|
Figure with Signal plot. |
smartreport.v3.plot.figures.signals.plot_signal_in_frequency(spectrum, vertical_lines_groups=None, peak_points=None, **kwargs)
Makes a figure that shows a RawDataSignalSpectrum in a frequency domain. The Y-axis is the signal frequency magnitude/amplitude in signal units, and the X-axis is the frequency in Hertz.
The figure uses a RawDataSignalSpectrum as a source of the frequency domain data.
Additionally, the x-axis can be limited with the hard_cut_off_high and dynamic_cut_off_high parameters.
Hard cut-off frequency is the maximum frequency in Hz that will be shown on the x-axis.
Dynamic cut-off frequency is a relative value (0.0, 1.0) that is used to find the minimum frequency
that keeps all signal values above the threshold.
The main trace is a line plot with the frequency domain representation of the signal.
The figure can show vertical lines on the plot. They are defined with the vertical_lines_groups parameter.
This can be used to show specific frequencies of interest, such as harmonics or sidebands.
Also, it can show peak points on the plot, which are defined with the peak_points parameter.
The figure uses a custom VerticalPlotLayout layout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spectrum
|
RawDataSignalSpectrum
|
RawDataSignalSpectrum to be plotted. |
required |
vertical_lines_groups
|
Optional[Sequence[SpectrumPointsGroup]]
|
List of VerticalLinesGroup objects to be plotted on the figure. |
None
|
peak_points
|
Optional[SpectrumPointsGroup]
|
Optional object with a collection of peak points to be plotted on the figure. |
None
|
Other Parameters:
| Name | Type | Description |
|---|---|---|
layout |
BaseLayout
|
Layout to be used. Default: |
cut_off_low |
float
|
Low cut-off frequency in Hertz. Default: |
cut_off_high |
float
|
High cut-off frequency in Hertz. Default: |
hard_cut_off_high |
float
|
Hard cut-off frequency in Hertz. Default: |
dynamic_cut_off_high |
float
|
Dynamic cut-off frequency, as a proportion to the signal maximum. Default: |
filter_order |
int
|
Filter order for FFT. Default: |
title |
str
|
Title of the plot. Default: |
color |
str
|
Color of the line. Default: |
use_logscale |
bool
|
Whether to use log scale for Y-axis. Default: |
x1_axis_title |
str
|
Title of the X-axis. Default: |
y1_axis_title |
str
|
Title of the Y-axis. Default: |
wrap_y_label |
bool
|
Whether to wrap Y-axis label. Default: |
use_scattergl |
bool
|
Whether to use a Scattergl trace type. Default: |
hover_precision |
int
|
Precision of the numbers in the hover template. Default: |
Returns:
| Type | Description |
|---|---|
FT
|
Figure with Signal plot in the frequency domain. |
Condition Indices
smartreport.v3.plot.figures.condition_indices.plot_threshold_crossing_index_details(df, **kwargs)
Plot the details of the Threshold Crossing Index.
It takes the input DataFrame with the condition index results data and creates a 4-row plot, with the following components:
- Input Signal
- Running State Input
- Extended Condition Index
- Condition Index Timeline
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
DataFrame containing the condition index results data. |
required |
Other Parameters:
| Name | Type | Description |
|---|---|---|
template |
str
|
Template to be used for the figure. Default: "simple_white" |
title |
str
|
Title of the figure. Default: "Threshold Crossing Index" |
subtitle |
str
|
Subtitle of the figure. Default: "" |
Returns:
| Type | Description |
|---|---|
Figure
|
A Plotly figure containing the Threshold Crossing Index details. |
smartreport.v3.plot.figures.condition_indices.plot_trend_detection_index_details(df, **kwargs)
Plot the details of the Trend Detection Index.
It takes the input DataFrame with the condition index results data and creates a 4-row plot, with the following components:
- Input Signal (with Holt Level if available)
- Running State Input
- Extended Condition Index (based on the Holt Trend)
- Condition Index Timeline
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
DataFrame containing the condition index results data. |
required |
Other Parameters:
| Name | Type | Description |
|---|---|---|
template |
str
|
Template to be used for the figure. Default: "simple_white" |
title |
str
|
Title of the figure. Default: "Trend Detection Index" |
subtitle |
str
|
Subtitle of the figure. Default: "" |
Returns:
| Type | Description |
|---|---|
Figure
|
A Plotly figure containing the Trend Detection Index details. |
smartreport.v3.plot.figures.condition_indices.plot_combined_index_details(dfs, **kwargs)
Plots the combined condition indices details.
This function creates a multi-row plot that combines the details of different condition indices into a single figure.
It includes the following components:
- Running State Input
- Input Signal (with thresholds and short-term and long-term trend lines)
- Condition Index Timeline for Threshold Crossing
- Condition Index Timeline for Short-Term Trend Detection
- Condition Index Timeline for Long-Term Trend Detection
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dfs
|
Dict[ConditionIndexModelType, DataFrame]
|
Dictionary containing DataFrames for each condition index type. |
required |
Other Parameters:
| Name | Type | Description |
|---|---|---|
template |
str
|
Template to be used for the figure. Default: "simple_white" |
title |
str
|
Title of the figure. Default: "Combined Condition Indices" |
subtitle |
str
|
Subtitle of the figure. Default: "" |
Returns:
| Type | Description |
|---|---|
Figure
|
A Plotly figure containing the combined condition indices details. |