in src/lookoutequipment/plot.py [0:0]
def __init__(self,
timeseries_df,
data_format,
timestamp_col=None,
tag_col=None,
resample=None,
verbose=False,
):
"""
Create a new instance to plot time series with different data structure
Parameters:
timeseries_df (pandas.DataFrame):
A dataframe containing time series data that you want to plot
data_format (string):
Use "timeseries" if your dataframe has three columns:
``timestamp``, ``values`` and ``tagname``. Use "tabular" if
``timestamp`` is your first column and all the other tags are
in the following columns: ``timestamp``, ``tag1``, ``tag2``...
timestamp_col (string):
Specifies the name of the columns that contains the
timestamps. If set to None, it means the timestamp is already
an index (default to None)
tag_col (string):
If data_format is "timeseries", this argument specifies what
is the name of the columns that contains the name of the tags
resample (string):
If specified, this class will resample the data before plotting
them. Use the same format than the string rule as used in the
``pandas.DataFrame.resample()`` method (default to None)
verbose (boolean):
If True, this class will print some messages along the way
(defaults to False)
"""
self._data = timeseries_df
self._format = data_format
self._timestamp_col = timestamp_col
self._tag_col = tag_col
self._tags_list = None
self._signals_to_plot = []
self._signals_data = []
self._tag_split = None
self._split_labels = []
self._start_date = None
self._end_date = None
self._labels_df = None
self._predictions_ranges = None
self._predictions_df = []
self._predictions_title = []
self._rolling_average = False
self._rolling_average_window = None
self._legend_format = {
'loc': 'upper right',
'framealpha': 0.5
}
self.verbose = verbose
self.resample = resample
# Prepare the figures:
self.fig_height = 4
self.height_ratios = []
self.nb_plots = 0
self.expanded_results = None
if self._format not in ['timeseries', 'tabular']:
raise Exception('`data_format` can only either be timeseries or tabular')
if (self._format == 'timeseries') and (self._tag_col is None):
raise Exception('`tag_col` must be defined when data format is timeseries')