ncplot.plot_time_series#

class ncplot.plot_time_series(*, figweb=None, data, labels, title='title', linecolors=None, fillcolors=None, cumul=False, date_ini_cumul=None, reference=None, ref_norm=None, mean_norm=False, mean_center=False, legendgroup=None, legendgrouptitle_text=None, stack=False, col=None, row=None, lwidths=None, lstyles=None, yaxis='y1', fill=None, mode='lines', markers=None, showlegend=True, visible=True, bar_widths=None)[source]#

Description#

This function provides a wrapper to facilitate the use of plotly.graph_objects class. It facilitates the input of several arguments:

  • data can be passed in any format

  • colors can be passed in any format (np.arrays, lists of strings…) which makes it possible to use indifferently plotly or matplotlib colormaps functions.

  • colors can be passed universally as linecolors and fillcolors argument, no matter what graphical function is used then by plotly (for instance go.Bar normally needs colors to be passed in the marker dict whereas go.Scatter needs colors to be passed in the line dict as well as through an fillcolor argument)

It also offers additional treatments in an easy way:
  • plot cumulative values

  • normalized values

This function is particularly appropriate to plot time series.

Example#

import cwatplot as cwp [_, _, figweb] = cwp.plot_time_series(data = [dfA, dfV],

labels = [‘Altrui’, ‘Vergogn’])

Parameters#

figweb: plotly figure

Can plot on top of a previous plotly figure.

data: array of pandas.DataFrames

Data to plot.

labels: array of strings

Texts for legend.

title: string

Title used for the matplotlib figure (fig1, ax1). Not used for plotly figure (figweb).

linecolors: np.array

Colors are stored in [R, G, B, Alpha]. For instance: linecolors = [[1.0, 0.5, 0.4, 1],[…]].

cumul: bool

Option to plot cumulated curves (True).

date_ini_cumul: string

The string should indicate the date in the format ‘YYYY-MM-DD’. (for instance: date_ini_cumul = ‘2000-07-31’) Only used when cumul = True.

reference: pandas.DataFrame

Used for displaying metrics (NSE, NSElog, VOLerr), computed against the reference data provided here.

ref_norm: pandas.DataFrame (or xarray.DataSet, beta version…)

Used for plotting values normalized against the provided reference data.

mean_norm: bool

Option to normalize each curve against its mean (True).

mean_center: bool

Option to center each curve on its mean (True).

legendgroup: string

To group curves under the provided group identifier. One group at a time.

legendgrouptitle_text:

Text associated with the group identifier.

stack: bool

Option to plot stacked curves (True).

col: int

Column number for subplots.

row: int

Row number for subplots.

visible: {True, False, “legendonly”}, optional, default True

Determines whether or not this trace is visible. If "legendonly", the trace is not drawn, but can appear as a legend item (provided that the legend itself is visible).

mode: {“markers”, “lines”, “lines+markers”, “bar”}, optional, default “lines”

To select the representation mode.

markers : list of dict

Returns#

fig1: matplotlib figure

OBSOLETE: recent developments (normalized curves, stacked curves…) have not been implemented in this figure.

ax1: matplotlib axis

Related to the previous figure. OBSOLETE.

figweb: plotly figure

This figure version includes all options.