graphpkg.live package
Contents
graphpkg.live package#
Module contents#
- class graphpkg.live.LiveDashboard(config: dict)[source]#
Bases:
object
Live Dashboard plot
- Parameters
config (dict) – Configuration Dictionary
Example
>>> conf = { >>> "dashboard": "DASHBOARD1", >>> "plots": { >>> "trend": [ >>> { >>> "func_for_data": func1, >>> "fig_spec": (4, 3, (1, 2)), >>> "interval": 500, >>> "title": "trend plot1" >>> }, >>> { >>> "func_for_data": func1, >>> "fig_spec": (4, 3, (4, 5)), >>> "interval": 500, >>> "title": "trend plot2" >>> }, >>> { >>> "func_for_data": func1, >>> "fig_spec": (4, 3, (7, 8)), >>> "interval": 500, >>> "title": "trend plot3" >>> }, >>> { >>> "func_for_data": func1, >>> "fig_spec": (4, 3, (10,11)), >>> "interval": 500, >>> "title": "trend plot4" >>> } >>> ], >>> "distribution": [{ >>> "fig_spec": (4, 3, (3,6)), >>> "func_for_data": func4, >>> "interval": 1000, >>> "title": "distribution plot", >>> "window": 500 >>> }], >>> "scatter": [ >>> { >>> "fig_spec": (4, 3, (9,12)), >>> "func_for_data": func3, >>> "func_args": (1000,), >>> "interval": 1000, >>> "title": "other other scatter plot", >>> "window": 500 >>> } >>> ] >>> } >>> } >>> dash = LiveDashboard(config=conf) >>> dash.start() >>> matplotlib.pyplot.show()
- property dash_config: List[Dict]#
Dash board configuration
- Returns
list of plots in a dictionary
- Return type
List[Dict]
- class graphpkg.live.LiveDistribution(interval: int, func_for_data: callable, func_args: Optional[Iterable] = None, fig: Optional[matplotlib.pyplot.figure] = None, fig_spec: tuple = (1, 1, 1), xlabel: str = 'x-axis', ylabel: str = 'y-axis', label: str = 'Current Data', title: str = 'Live Scatter', window: int = 2000)[source]#
Bases:
graphpkg.live._graph.Graph
Live Distribution Graph Module
- Parameters
func_for_data (callable) – Function to return x and y data point.x is a single value and y can be a list of max length 3 or a single value. both of them shouldn’t be None.
Example –
>>> def get_new_data(): >>> return 10,10
>>> def get_new_data(): >>> ## first param for x axis and second can be an array of values >>> return 10,[10,11]
>>> def func1(*args): >>> return random.randrange(1, args[0]),random.randrange(1, args[0])
func_args (Iterable, optional) – data function arguments. Defaults to None.
fig (matplotlib.pyplot.figure, optional) – .Matplotlib figure. Defaults to None.
fig_spec (tuple, optional) – [description]. Matplotlib figure specification. Defaults to (1,1,1).
interval (int) – Interval to refresh data in milliseconds.
xlabel (str, optional) – Label for x-axis. Defaults to “x-axis”.
ylabel (str, optional) – Label for y-axis. Defaults to “y-axis”.
label (str, optional) – Label for plot line. Defaults to “Current Data”.
title (str, optional) – Title of Scatter chart. Defaults to “Live Scatter”.
window (int, optional) – Data point window. Defaults to 500.
Examples
>>> def func1(): return None, random.randrange(1,100) >>> g1 = LiveDistribution(func_for_data=func1,interval=1000,title="plot 1 for range 1-100") >>> g1.start() >>> plt.show()
- property xs: List[graphpkg.live._graph.A]#
x-axis data list
- Returns
x-axis list
- Return type
List[A]
- property ys: List[graphpkg.live._graph.A]#
y-axis data list
- Returns
y-axis list of lists
- Return type
List[A]
- class graphpkg.live.LiveScatter(interval: int, func_for_data: callable, func_args: Optional[Iterable] = None, fig: Optional[matplotlib.pyplot.figure] = None, fig_spec: tuple = (1, 1, 1), xlabel: str = 'x-axis', ylabel: str = 'y-axis', label: str = 'Current Data', title: str = 'Live Scatter', window: int = 500)[source]#
Bases:
graphpkg.live._graph.Graph
Live Scatter Graph Module
- Parameters
func_for_data (callable) – Function to return x and y data point.x is a single value and y can be a list of max length 3 or a single value. both of them shouldn’t be None.
Example –
>>> def get_new_data(): >>> return 10,10
>>> def get_new_data(): >>> ## first param for x axis and second can be an array of values >>> return 10,[10,11]
>>> def func1(*args): >>> return random.randrange(1, args[0]),random.randrange(1, args[0])
func_args (Iterable, optional) – data function arguments. Defaults to None.
fig (matplotlib.pyplot.figure, optional) – .Matplotlib figure. Defaults to None.
fig_spec (tuple, optional) – [description]. Matplotlib figure specification. Defaults to (1,1,1).
interval (int) – Interval to refresh data in milliseconds.
xlabel (str, optional) – Label for x-axis. Defaults to “x-axis”.
ylabel (str, optional) – Label for y-axis. Defaults to “y-axis”.
label (str, optional) – Label for plot line. Defaults to “Current Data”.
title (str, optional) – Title of Scatter chart. Defaults to “Live Scatter”.
window (int, optional) – Data point window. Defaults to 500.
Examples
>>> scatter = LiveScatter(func_for_data = get_new_data, interval=1000) >>> scatter.start() >>> matplotlib.pyplot.show()
>>> scatter = LiveScatter(func_for_data = get_new_data, interval=1000, window=30) >>> scatter.start() >>> matplotlib.pyplot.show()
>>> scatter = LiveScatter(func_for_data = get_new_data,func_args=(1000,), interval=1000, title="my test data") >>> scatter.start() >>> matplotlib.pyplot.show()
- property xs: List[graphpkg.live._graph.A]#
x-axis data list
- Returns
x-axis list
- Return type
List[A]
- property ys: List[graphpkg.live._graph.A]#
y-axis data list
- Returns
y-axis list of lists
- Return type
List[A]
- class graphpkg.live.LiveTrend(interval: int, func_for_data: callable, func_args: Optional[Iterable] = None, fig: Optional[matplotlib.pyplot.figure] = None, fig_spec: tuple = (1, 2, (1, 2)), xlabel: str = 'x-axis', ylabel: str = 'y-axis', label: str = 'Current Data', title: str = 'Live Trend', window: int = 50)[source]#
Bases:
graphpkg.live._graph.Graph
Live Trend Graph Module
- Parameters
func_for_data (callable) – Function to return x and y data points.x is a single value and y can be a list of max length 3 or a single value.
Example –
>>> def get_new_data(): >>> return datetime.datetime.now(),10
>>> def get_new_data(): >>> return None,10
>>> def get_new_data(): >>> ## first param for x axis and second can be an array of values >>> return datetime.datetime.now(),[10,11]
>>> def func1(*args): >>> return datetime.datetime.now(),random.randrange(1, args[0])
func_args (Iterable, optional) – data function arguments. Defaults to None.
fig (matplotlib.pyplot.figure, optional) – .Matplotlib figure. Defaults to None.
fig_spec (tuple, optional) – [description]. Matplotlib figure specification. Defaults to (1,2,(1,2)).
interval (int) – Interval to refresh data in milliseconds.
xlabel (str, optional) – Label for x-axis. Defaults to “x-axis”.
ylabel (str, optional) – Label for y-axis. Defaults to “y-axis”.
label (str, optional) – Label for plot line. Defaults to “Current Data”.
title (str, optional) – Title of trend chart. Defaults to “Live Trend”.
window (int, optional) – Data point window. Defaults to 50.
Examples
>>> trend = LiveTrend(func_for_data = get_new_data, interval=1000) >>> trend.start() >>> matplotlib.pyplot.show()
>>> trend = LiveTrend(func_for_data = get_new_data, interval=1000, window=30) >>> trend.start() >>> matplotlib.pyplot.show()
>>> trend = LiveTrend(func_for_data = get_new_data, interval=1000, title="my test data") >>> trend.start() >>> matplotlib.pyplot.show()
- property xs: List[graphpkg.live._graph.A]#
x-axis data list
- Returns
x-axis list
- Return type
List[A]
- property ys: List[graphpkg.live._graph.A]#
y-axis data list
- Returns
y-axis list of lists
- Return type
List[A]